package cn.fl.insurance.controller;

import cmm.comm.facade.framework.api.ISysCdMapApiService;
import cmm.comm.facade.upload.constant.SysUlFilesRecConstant;
import cmm.comm.facade.upload.dto.SysUlFilesRecDTO;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.*;
import cn.cmm.cache.framework.utils.PropertiesCacheUtils;
import cn.fl.capital.condition.CapFeeOutLogQueryCondition;
import cn.fl.capital.constant.CapitalConstant;
import cn.fl.capital.service.ICapFeeOutLogService;
import cn.fl.capital.service.ICapPayInfoService;
import cn.fl.capital.vo.CapFeeOutLogVO;
import cn.fl.capital.vo.CapPayInfoVO;
import cn.fl.commons.result.ResponseData;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.insurance.condition.InsChnOpenSettingQueryCondition;
import cn.fl.insurance.condition.InsCompInfoQueryCondition;
import cn.fl.insurance.condition.InsPlcBscInfoQueryCondition;
import cn.fl.insurance.constant.InsuranceConstant;
import cn.fl.insurance.dto.InsCompInfoDTO;
import cn.fl.insurance.service.*;
import cn.fl.insurance.transform.InsCompInfoVOTransform;
import cn.fl.insurance.vo.*;
import cn.fl.preloan.dto.insurance.*;
import cn.fl.project.condition.PrjPrdDtlForInsQueryCondition;
import cn.fl.project.condition.PrjPrdPaySchDQueryCondition;
import cn.fl.project.condition.PrjPrdPaySchMQueryCondition;
import cn.fl.project.constant.PrjPrdPaySchMConstant;
import cn.fl.project.dto.PrjPrdDtlForInsDTO;
import cn.fl.project.service.*;
import cn.fl.project.vo.*;
import cn.fl.system.constant.SysLogConstant;
import cn.fl.system.service.ISysUlDatCfgService;
import cn.fl.system.service.ISysUlFilesRecService;
import cn.fl.system.transform.SysUlFilesRecVOTransform;
import cn.fl.system.vo.SysUlFilesRecVO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import fl.customer.facade.customer.dto.CstBscInfoDTO;
import net.sf.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;

/**
 * @Description: 保险管理 控制层
 */
@Controller
@RequestMapping("/insurance/insPlcBscInfo")
public class InsPlcBscInfoController extends BaseController {

	private static final Logger logger = LoggerFactory.getLogger(InsPlcBscInfoController.class);

    /**
     * InsPlcBscInfo 服务层BEAN
     */
    @Autowired
    private IInsPlcBscInfoService insPlcBscInfoService;
    /**
     * InsTypInfo 服务层BEAN
     */
    @Autowired
    private IInsTypInfoService insTypInfoService;
    /**
     * InsCompInfo 服务层BEAN
     */
    @Autowired
    private IInsCompInfoService insCompInfoService;
    /**
     * InsPlcPrdDtlTk 服务层BEAN
     */
    @Autowired
    private IInsPlcPrdDtlTkService insPlcPrdDtlTkService;

    /**
     * InsCompChnPol 服务层BEAN
     */
    @Autowired
    private IInsCompChnPolService insCompChnPolService;
    @Autowired
    private IInsChnOpenSettingService insChnOpenSettingService;
    @Autowired
    private IPrjPrdPaySchDService prjPrdPaySchDService;
    @Autowired
    private IPrjPrdDtlService prjPrdDtlService;
    @Autowired
    private IPrjPrdBscInfoService prjPrdBscInfoService;
    @Autowired
    private ISysCdMapApiService sysCdMapApiService;
    @Autowired
    private ICapFeeOutLogService capFeeOutLogService;

    @Autowired
    private ISysUlFilesRecService sysUlFilesRecService;
    @Autowired
    private ICapPayInfoService capPayInfoService;

    @Autowired
    private IPrjPrdPaySchMService prjPrdPaySchMService ;
    @Autowired
    private IPrjBscInfoService prjBscInfoService;

    @Autowired
    private ISysUlDatCfgService sysUlDatCfgService;

    @Autowired IProjectApiService projectApiService;
    /**
     * 贷前保单服务
     */
    @Autowired
    private cn.fl.preloan.IInsPlcBscInfoService iInsPlcBscInfoService;


    /**
     * 到保险管理列表页面
     */
    @RequestMapping(value = "/toListPage.do", method = {RequestMethod.GET})
    public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toListPage", "加载保险管理列表页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("insurance/insPlcBscInfo/insPlcBscInfoList");
        //保险公司
        InsCompInfoQueryCondition qc = new InsCompInfoQueryCondition();
        qc.setCompLvl(1);
        List<InsCompInfoDTO> insCompList = this.insCompInfoService.searchList(qc);
        if (CollectionUtils.isNotEmpty(insCompList)) {
            mav.addObject("insCompList", JSON.toJSONString(InsCompInfoVOTransform.toVOList(insCompList)));
        }
        return mav;
    }

    /**
     * 到新增保单页面
     */
    @RequestMapping(value = "/toAddPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toAddPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toAddPage", "加载到新增保单页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("insurance/insPlcBscInfo/insPlcBscInfoModify");
        //加载数据字典
        this.prepare(request, mav);

        //从request中请求信息
        String prjPrdDtlId = request.getParameter("prjPrdDtlId");//项目产品明细ID
        String prjId = request.getParameter("prjId");//项目ID
        String cstId = request.getParameter("cstId");
        String insTypCd = request.getParameter("insTypCd");
        if(StringUtils.isEmpty(prjId)||StringUtils.isEmpty(prjPrdDtlId)||StringUtils.isEmpty(cstId)){
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "产品明细主键为空");
        }
        mav.addObject("prjPrdDtlId", prjPrdDtlId);
        mav.addObject("prjId", prjId);
        mav.addObject("ctrlKey", "1");//控制保单附件维护 1.可上传删除 2.审核
        //查询保单号历史数据
        /*InsPlcBscInfoQueryCondition qc1 = new InsPlcBscInfoQueryCondition();
        List<InsPlcBscInfoVO> insPlcBscInfoLicNo =  this.insPlcBscInfoService.selectListLicNo();
        for (InsPlcBscInfoVO insPlcBscInfoVO2 : insPlcBscInfoLicNo) {
        	if(null != insPlcBscInfoVO2){
        		String LSplcNo = insPlcBscInfoVO2.getPlcNo();
            	if(StringUtils.isNotBlank(LSplcNo)){
            		mav.addObject("LSplcNo",LSplcNo);
    		    }
        	}
        	
       }*/
      //项目类型查询
       PrjBscInfoVO prjbsc = this.prjBscInfoService.selectById(Long.valueOf(prjId));
       if(null != prjbsc){
           String prjTypCd = prjbsc.getPrjTypCd();
           mav.addObject("prjTypCd",prjTypCd);
           if(null != prjbsc.getInsCode()){
               mav.addObject("insCode",prjbsc.getInsCode());
           }
       }
       //资产状态查询
       PrjPrdDtlVO prjPrdDtl = this.prjPrdDtlService.selectById(Long.valueOf(prjPrdDtlId));
       if(null != prjPrdDtl){
    	   String prdStsCd = prjPrdDtl.getPrdStsCd();
			   mav.addObject("prdStsCd",prdStsCd);
       }
        InsPlcBscInfoVO insPlcBscInfoVO = new InsPlcBscInfoVO();
        insPlcBscInfoVO.setPrjId(Long.valueOf(prjId));
        insPlcBscInfoVO.setPrjPrdDtlId(Long.valueOf(prjPrdDtlId));
        PrjPrdPaySchMQueryCondition queryCondition = new PrjPrdPaySchMQueryCondition();
        queryCondition.setPrjId(StringUtils.isNotBlank(prjId) ? Long.valueOf(prjId):null);
        queryCondition.setPrjPrdDtlId(StringUtils.isNotBlank(prjPrdDtlId) ? Long.valueOf(prjPrdDtlId):null);
        queryCondition.setPaySchTypCd(PrjPrdPaySchMConstant.PAY_SCH_TYP_CD_WS);
        List<PrjPrdPaySchMVO> prjPrdPaySchMVOs = this.prjPrdPaySchMService.searchList(queryCondition);
        PrjPrdPaySchMVO prjPrdPaySchMVO = null ;
        if(CollectionUtils.isNotEmpty(prjPrdPaySchMVOs)){
             prjPrdPaySchMVO = prjPrdPaySchMVOs.get(0);
        }
        String insPlcFstPerCd = null ;
        if(null != prjPrdPaySchMVO){
            insPlcFstPerCd = prjPrdPaySchMVO.getBizFlag();
//            insPlcBscInfoVO.setFstPer(prjPrdPaySchMVO.getBizFlag());
        }else{
            insPlcFstPerCd = InsuranceConstant.CODE_INS_PLC_FST_PER_CD_1 ;
//            insPlcBscInfoVO.setFstPer(InsuranceConstant.CODE_INS_PLC_FST_PER_CD_1);
        }
        List<KeyValueVO> fstPerTypCdList = this.insPlcBscInfoService.searchInsFstPerTypCdList();//保单第一受益人
        if(CollectionUtils.isNotEmpty(fstPerTypCdList)){
            for(KeyValueVO vo : fstPerTypCdList){
                if(vo.getKey().equals(insPlcFstPerCd)){
                    insPlcBscInfoVO.setFstPer(vo.getValue());
                    break ;
                }
            }
        }
        if(null == insPlcBscInfoVO.getFstPer()){
            insPlcBscInfoVO.setFstPer(InsuranceConstant.CODE_INS_PLC_FST_PER_DEFAULT_CD_NM);
        }

        //查询被保险人信息
        CstBscInfoDTO cstBscInfoDTO = this.insPlcBscInfoService.selectPlcCstInfo(Long.valueOf(cstId));
        if (null != cstBscInfoDTO) {
            insPlcBscInfoVO.setInsPerNm(cstBscInfoDTO.getCstNm());
            insPlcBscInfoVO.setInsPerCretNo(cstBscInfoDTO.getCertNo());
            insPlcBscInfoVO.setCstId(cstBscInfoDTO.getId());
            insPlcBscInfoVO.setCstNm(cstBscInfoDTO.getCstNm());
        }

        //默认设置保险种类为商业险
        insPlcBscInfoVO.setInsTypCd(InsuranceConstant.CODE_INS_TYP_CD_1);
        //购买方式默认 我司购买
        insPlcBscInfoVO.setBuyWayCd(InsuranceConstant.CODE_INS_BUY_WAY_CD_1);
        //保单性质 首年保单
        insPlcBscInfoVO.setPlcPropCd(InsuranceConstant.CODE_INS_PLC_NAT_CD_1);

        PrjBscInfoVO prjBscInfoVO = this.insPlcBscInfoService.searchPrjBscInfo(Long.parseLong(prjId));
        if (null != prjBscInfoVO) {
            mav.addObject("contNo",prjBscInfoVO.getLsCntNo());
            mav.addObject("prjTypCd", prjBscInfoVO.getPrjTypCd());
            mav.addObject("bizTypCd", prjBscInfoVO.getBizTypCd());
            //mav.addObject("rgnCd","0,"+prjBscInfoVO.getRgnPrCd()+","+prjBscInfoVO.getRgnCyCd());
            mav.addObject("orgCd", prjBscInfoVO.getCstMgrOrgCd());
            mav.addObject("buOrgCd",prjBscInfoVO.getBuOrgCd());
            //暂时处理一下
            if(InsuranceConstant.INS_PRJ_BU_ORG_CD_5.equals(prjBscInfoVO.getBuOrgCd())){
                mav.setViewName("insurance/insPlcBscInfo/insPlcBscInfoAdd");
            }else{
                //查询项目产品明细信息
                PrjPrdDtlForInsQueryCondition qc = new PrjPrdDtlForInsQueryCondition();
                qc.setId(Long.valueOf(prjPrdDtlId));
                qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
                qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
                List<PrjPrdDtlForInsDTO> prdList = this.insPlcBscInfoService.searchInsurePrdList(qc);

                //项目产品类型 ：挂车标示 1.挂车 0.非挂车
                mav.addObject("isTrailer",BaseConstant.IS_YESNO_NO);
                if(CollectionUtils.isNotEmpty(prdList)){
                    PrjPrdDtlForInsDTO prjPrdDtlForInsDTO=prdList.get(0);
                    mav.addObject("paySchNo", prjPrdDtlForInsDTO.getPaySchNo());
                    mav.addObject("paySchId", prjPrdDtlForInsDTO.getPaySchId());
                    mav.addObject("actPrdId", prjPrdDtlForInsDTO.getActPrdId());//车辆实际ID

                    String prdTypCd = prjPrdDtlForInsDTO.getPrdTypCd();
                    if(StringUtils.isNotEmpty(prdTypCd)){
                        if(prdTypCd.startsWith(InsuranceConstant.CODE_PRD_TYP_CD_006)||prdTypCd.startsWith(InsuranceConstant.CODE_PRD_TYP_CD_014)
                                ||prdTypCd.startsWith(InsuranceConstant.CODE_PRD_TYP_CD_015)){
                            //挂车 不用上传交强险保单
                            mav.addObject("isTrailer",BaseConstant.IS_YESNO_YES);
                        }
                    }
                }
            }
        }
        //设置保险种类
        if (StringUtils.isNotEmpty(insTypCd)) {
            insPlcBscInfoVO.setInsTypCd(insTypCd);
        }
        mav.addObject("insPlcBscInfoVO", insPlcBscInfoVO);
        return mav;
    }

    /**
     * 到新增续保保单页面
     */
    @RequestMapping(value = "/toAddRenewPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toAddRenewPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toAddPage", "加载到新增续保保单页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("insurance/insPlcBscInfo/insPlcBscInfoModify");

        List<KeyValueVO> fstPerTypCdList = this.insPlcBscInfoService.searchInsFstPerTypCdList();//保单第一受益人

        //从request中请求信息
        String renewId = request.getParameter("renewId");//续保保单号
        String plcId = request.getParameter("plcId");//老保单号
        String flag = request.getParameter("flag");//是否显示发起流程按钮 默认不显示 0:否 1.是
        if (StringUtils.isNotBlank(flag)) {
            mav.addObject("flowFlag", Integer.parseInt(flag));
        } else {
            mav.addObject("flowFlag", 0);
        }
        if(StringUtils.isNotEmpty(plcId)){
            mav.addObject("plcId", plcId);
        }

        String prjPrdDtlId = request.getParameter("prjPrdDtlId");//项目产品明细
        if (StringUtils.isNotBlank(prjPrdDtlId)) {
            mav.addObject("prjPrdDtlId", prjPrdDtlId);
        }

        mav.addObject("ctrlKey", "1");//控制保单附件维护 1.可上传删除 2.审核
        Long id = 0L;//保单ID
        InsPlcBscInfoVO insPlcBscInfoVO = null;
        if (StringUtils.isNotEmpty(renewId)) {//续保保单ID
            //查询保单信息
            GetInsPlcBscInfoRequest getRequest = new GetInsPlcBscInfoRequest();
            getRequest.setId(Long.parseLong(renewId));
            ResponseData<InsPlcBscInfoDTO> responseData = this.iInsPlcBscInfoService.selectById(getRequest);
            InsPlcBscInfoVO plcBscInfoVO = new InsPlcBscInfoVO();
            if (null != responseData && ResponseData.SUCCESS_CODE.equals(responseData.getCode()) && null != responseData.getData()){
                insPlcBscInfoVO = new InsPlcBscInfoVO();
                InsPlcBscInfoDTO dto = responseData.getData();
                BeanUtils.copyProperties(dto,plcBscInfoVO);
            }
            id = insPlcBscInfoVO.getId();
            if (insPlcBscInfoVO.getPlcBgTm() != null) {
                insPlcBscInfoVO.setPlcBgTms(DateUtils.formatDateToString(insPlcBscInfoVO.getPlcBgTm(), DateUtils.YYYY_MM_DD));
            }
            if (insPlcBscInfoVO.getPlcEndTm() != null) {
                insPlcBscInfoVO.setPlcEndTms(DateUtils.formatDateToString(insPlcBscInfoVO.getPlcEndTm(), DateUtils.YYYY_MM_DD));
            }
            if (insPlcBscInfoVO.getInsTtlFee() != null) {
                insPlcBscInfoVO.setInsTtlFeeDb(DecimalUtils.convertFenToYuan(insPlcBscInfoVO.getInsTtlFee()));
            }
            PrjPrdPaySchMVO prjPrdPaySchMVO = this.prjPrdPaySchMService.selectById(insPlcBscInfoVO.getPaySchId());
            String insPlcFstPerCd = null ;
            if(null != prjPrdPaySchMVO){
                insPlcFstPerCd = prjPrdPaySchMVO.getBizFlag();
//            insPlcBscInfoVO.setFstPer(prjPrdPaySchMVO.getBizFlag());
            }else{
                insPlcFstPerCd = InsuranceConstant.CODE_INS_PLC_FST_PER_CD_1 ;
//            insPlcBscInfoVO.setFstPer(InsuranceConstant.CODE_INS_PLC_FST_PER_CD_1);
            }
            if(CollectionUtils.isNotEmpty(fstPerTypCdList)){
                for(KeyValueVO vo : fstPerTypCdList){
                    if(vo.getKey().equals(insPlcFstPerCd)){
                        insPlcBscInfoVO.setFstPer(vo.getValue());
                        break ;
                    }
                }
            }
            if(null == insPlcBscInfoVO.getFstPer()){
                insPlcBscInfoVO.setFstPer(InsuranceConstant.CODE_INS_PLC_FST_PER_DEFAULT_CD_NM);
            }
            mav.addObject("insPlcBscInfoVO", insPlcBscInfoVO);
        }else if (StringUtils.isNotEmpty(plcId)) {
            GetInsPlcBscInfoRequest getRequest = new GetInsPlcBscInfoRequest();
            getRequest.setId(Long.valueOf(plcId));
            ResponseData responseData = iInsPlcBscInfoService.selectById(getRequest);
            BaseLogUtils.info(logger, "selectById", "贷前--获取InsPlcBscInfo数据，request:" +
                    JSONObject.toJSONString(getRequest) + ",response:" + JSONObject.toJSONString(responseData), CurrentThreadContext.getCurrentUserName());
            //insPlcBscInfoVO = this.insPlcBscInfoService.selectById(Long.parseLong(plcId));
            if (responseData != null && responseData.getData() != null) {
                InsPlcBscInfoDTO dto = (InsPlcBscInfoDTO) responseData.getData();
                insPlcBscInfoVO = new InsPlcBscInfoVO();
                BeanUtils.copyProperties(dto,insPlcBscInfoVO);
            }
            if (null != insPlcBscInfoVO) {
                InsPlcBscInfoVO vo = new InsPlcBscInfoVO();
                vo.setId(insPlcBscInfoVO.getId());
                vo.setPlcPropCd(InsuranceConstant.CODE_INS_PLC_NAT_CD_2);
                vo.setInsTypCd(insPlcBscInfoVO.getInsTypCd());
                vo.setPrdTypCd(insPlcBscInfoVO.getPrdTypCd());
                vo.setInsPerNm(insPlcBscInfoVO.getInsPerNm());
                vo.setInsPerCretNo(insPlcBscInfoVO.getInsPerCretNo());
                PrjPrdPaySchMVO prjPrdPaySchMVO = this.prjPrdPaySchMService.selectById(insPlcBscInfoVO.getPaySchId());
                String insPlcFstPerCd = null ;
                if(null != prjPrdPaySchMVO){
                    insPlcFstPerCd = prjPrdPaySchMVO.getBizFlag();
//            insPlcBscInfoVO.setFstPer(prjPrdPaySchMVO.getBizFlag());
                }else{
                    insPlcFstPerCd = InsuranceConstant.CODE_INS_PLC_FST_PER_CD_1 ;
//            insPlcBscInfoVO.setFstPer(InsuranceConstant.CODE_INS_PLC_FST_PER_CD_1);
                }
                if(CollectionUtils.isNotEmpty(fstPerTypCdList)){
                    for(KeyValueVO keyValueVO : fstPerTypCdList){
                        if(keyValueVO.getKey().equals(insPlcFstPerCd)){
                            vo.setFstPer(keyValueVO.getValue());
                            break ;
                        }
                    }
                }
                if(null == vo.getFstPer()){
                    vo.setFstPer(InsuranceConstant.CODE_INS_PLC_FST_PER_DEFAULT_CD_NM);
                }
                vo.setBuyWayCd(InsuranceConstant.CODE_INS_BUY_WAY_CD_1);
                mav.addObject("insPlcBscInfoVO", vo);
            }
        }

        if (null != insPlcBscInfoVO) {
            mav.addObject("paySchId", insPlcBscInfoVO.getPaySchId());//支付表ID
            mav.addObject("paySchNo", insPlcBscInfoVO.getPaySchNo());//支付表号
            mav.addObject("prjPrdDtlId", insPlcBscInfoVO.getPrjPrdDtlId());

            mav.addObject("contNo", insPlcBscInfoVO.getContNo());
            mav.addObject("prjId", insPlcBscInfoVO.getPrjId());
            if (StringUtils.isNotEmpty(insPlcBscInfoVO.getPrjId())) {
                PrjBscInfoVO prjBscInfoVO = this.insPlcBscInfoService.searchPrjBscInfo(insPlcBscInfoVO.getPrjId());
                if (null != prjBscInfoVO) {
                    mav.addObject("prjTypCd", prjBscInfoVO.getPrjTypCd());
                    mav.addObject("bizTypCd", prjBscInfoVO.getBizTypCd());
                    //mav.addObject("rgnCd","0,"+prjBscInfoVO.getRgnPrCd()+","+prjBscInfoVO.getRgnCyCd());
                    mav.addObject("orgCd", prjBscInfoVO.getCstMgrOrgCd());
                }
            }

            /*//查询保单产品信息
            InsPlcPrdDtlTkQueryCondition prdDtlQueryCondition = new InsPlcPrdDtlTkQueryCondition();
            prdDtlQueryCondition.setInsPlcId(id);
            List<InsPlcPrdDtlTkVO> prdList = insPlcPrdDtlTkService.searchList(prdDtlQueryCondition);
            mav.addObject("prdList", JSON.toJSONString(prdList));
            if (StringUtils.isBlank(prjPrdDtlId)) {
                if (CollectionUtils.isNotEmpty(prdList)) {
                    mav.addObject("prjPrdDtlId", prdList.get(0).getPrjPrdDtlId());
                }
            }*/

            //项目产品类型 ：挂车标示 1.挂车 0.非挂车
            mav.addObject("isTrailer",BaseConstant.IS_YESNO_NO);
            if(StringUtils.isNotEmpty(insPlcBscInfoVO.getPrjPrdDtlId())){
                PrjPrdDtlVO prjPrdDtlVO = this.prjPrdDtlService.selectById(insPlcBscInfoVO.getPrjPrdDtlId());
                if(null != prjPrdDtlVO){
                    PrjPrdBscInfoVO prjPrdBscInfoVO = this.prjPrdBscInfoService.selectById(prjPrdDtlVO.getPrjPrdId());
                    if(null != prjPrdBscInfoVO){
                        String prdTypCd = prjPrdBscInfoVO.getPrdTypCd();
                        if(StringUtils.isNotEmpty(prdTypCd)){
                            if(prdTypCd.startsWith(InsuranceConstant.CODE_PRD_TYP_CD_006)||prdTypCd.startsWith(InsuranceConstant.CODE_PRD_TYP_CD_014)
                                    ||prdTypCd.startsWith(InsuranceConstant.CODE_PRD_TYP_CD_015)){
                                //挂车 不用上传交强险保单
                                mav.addObject("isTrailer",BaseConstant.IS_YESNO_YES);
                            }
                        }
                    }
                }
            }
        }
        this.prepare(request, mav);
        List<KeyValueVO> plcPropCdList = this.insPlcBscInfoService.searchPlcPropCdList();//保单性质
        for (KeyValueVO vo : plcPropCdList) {
            if (InsuranceConstant.CODE_INS_PLC_NAT_CD_1.equals(vo.getKey())) {//去除首年保单项
                plcPropCdList.remove(vo);
            }
        }
        mav.addObject("plcPropCdList", JSON.toJSONString(plcPropCdList));

        return mav;
    }

    /**
     * 到修改保单页面
     */
    @RequestMapping(value = "/toModifyPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toModifyPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toModifyPage", "加载到修改保单页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("insurance/insPlcBscInfo/insPlcBscInfoModify");
        this.prepare(request, mav);

        String id = request.getParameter("id");
        String prjId = request.getParameter("prjId");
        String wsPaySchId = request.getParameter("wsPaySchId");
        String prjPrdChangeFlag = request.getParameter("prjPrdChangeFlag");
        if(StringUtils.isEmpty(id)){
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "保单主键为空");
        }
        GetInsPlcBscInfoRequest infoRequest = new GetInsPlcBscInfoRequest();
        infoRequest.setId(Long.valueOf(id));
        ResponseData responseData = iInsPlcBscInfoService.selectById(infoRequest);
        InsPlcBscInfoVO insPlcBscInfoVO = null;
        if (responseData != null && responseData.getData() != null) {
            InsPlcBscInfoDTO insPlcBscInfoDTO = (InsPlcBscInfoDTO) responseData.getData();
            insPlcBscInfoVO = new InsPlcBscInfoVO();
            BeanUtils.copyProperties(insPlcBscInfoDTO,insPlcBscInfoVO);
        }
        /*InsPlcBscInfoVO insPlcBscInfoVO = this.insPlcBscInfoService.selectById(Long.valueOf(id));*/        if (insPlcBscInfoVO.getPlcBgTm() != null) {
            insPlcBscInfoVO.setPlcBgTms(DateUtils.formatDateToString(insPlcBscInfoVO.getPlcBgTm(), DateUtils.YYYY_MM_DD));
        }
        if (insPlcBscInfoVO.getPlcEndTm() != null) {
            insPlcBscInfoVO.setPlcEndTms(DateUtils.formatDateToString(insPlcBscInfoVO.getPlcEndTm(), DateUtils.YYYY_MM_DD));
        }
        if (insPlcBscInfoVO.getInsTtlFee() != null) {
            insPlcBscInfoVO.setInsTtlFeeDb(DecimalUtils.convertFenToYuan(insPlcBscInfoVO.getInsTtlFee()));
        }
        Long paySchId = insPlcBscInfoVO.getPaySchId();
        if (paySchId == null && StringUtils.isNotEmpty(wsPaySchId)) {
            paySchId = Long.valueOf(wsPaySchId);
        }
        PrjPrdPaySchMVO prjPrdPaySchMVO = this.prjPrdPaySchMService.selectById(paySchId);
        String insPlcFstPerCd = "" ;
        if(null != prjPrdPaySchMVO){
            insPlcFstPerCd = prjPrdPaySchMVO.getBizFlag();
//            insPlcBscInfoVO.setFstPer(prjPrdPaySchMVO.getBizFlag());
        }else{
            insPlcFstPerCd = InsuranceConstant.CODE_INS_PLC_FST_PER_CD_1 ;
//            insPlcBscInfoVO.setFstPer(InsuranceConstant.CODE_INS_PLC_FST_PER_CD_1);
        }
        List<KeyValueVO> fstPerTypCdList = this.insPlcBscInfoService.searchInsFstPerTypCdList();//保单第一受益人
        if(CollectionUtils.isNotEmpty(fstPerTypCdList)){
            for(KeyValueVO vo : fstPerTypCdList){
                if(vo.getKey().equals(insPlcFstPerCd)){
                    insPlcBscInfoVO.setFstPer(vo.getValue());
                    break ;
                }
            }
        }
        if(null == insPlcBscInfoVO.getFstPer()){
            insPlcBscInfoVO.setFstPer(InsuranceConstant.CODE_INS_PLC_FST_PER_DEFAULT_CD_NM);
        }
        mav.addObject("insPlcBscInfoVO", insPlcBscInfoVO);
        mav.addObject("paySchId", paySchId);//支付表ID
        mav.addObject("paySchNo", insPlcBscInfoVO.getPaySchNo());//支付表号
        mav.addObject("prjPrdDtlId", insPlcBscInfoVO.getPrjPrdDtlId());//项目产品明细ID
        //换车标志
        mav.addObject("prjPrdChangeFlag", prjPrdChangeFlag);

        Long projectId = insPlcBscInfoVO.getPrjId();
        if (projectId == null && StringUtils.isNotEmpty(prjId)) {
            projectId = Long.valueOf(prjId);
        }
        mav.addObject("prjId", projectId);
        PrjBscInfoVO prjBscInfoVO = this.insPlcBscInfoService.searchPrjBscInfo(projectId);
        if (null != prjBscInfoVO) {
            mav.addObject("prjTypCd", prjBscInfoVO.getPrjTypCd());
            mav.addObject("bizTypCd", prjBscInfoVO.getBizTypCd());
            //mav.addObject("rgnCd","0,"+prjBscInfoVO.getRgnPrCd()+","+prjBscInfoVO.getRgnCyCd());
            mav.addObject("orgCd", prjBscInfoVO.getCstMgrOrgCd());
            mav.addObject("buOrgCd",prjBscInfoVO.getBuOrgCd());

            //暂时处理一下
            if(InsuranceConstant.INS_PRJ_BU_ORG_CD_5.equals(prjBscInfoVO.getBuOrgCd())){
                mav.setViewName("insurance/insPlcBscInfo/insPlcBscInfoAdd");
            }else{
                //查询项目产品明细信息  (重复查询 待优化)
                PrjPrdDtlForInsQueryCondition qc = new PrjPrdDtlForInsQueryCondition();
                qc.setId(insPlcBscInfoVO.getPrjPrdDtlId());
                qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
                qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
                List<PrjPrdDtlForInsDTO> prdList = this.insPlcBscInfoService.searchInsurePrdList(qc);

                //项目产品类型 ：挂车标示 1.挂车 0.非挂车
                mav.addObject("isTrailer",BaseConstant.IS_YESNO_NO);
                if(CollectionUtils.isNotEmpty(prdList)){
                    PrjPrdDtlForInsDTO prjPrdDtlForInsDTO=prdList.get(0);
                    mav.addObject("actPrdId", prjPrdDtlForInsDTO.getActPrdId());//车辆实际ID

                    String prdTypCd = prjPrdDtlForInsDTO.getPrdTypCd();
                    if(StringUtils.isNotEmpty(prdTypCd)){
                        if(prdTypCd.startsWith(InsuranceConstant.CODE_PRD_TYP_CD_006)||prdTypCd.startsWith(InsuranceConstant.CODE_PRD_TYP_CD_014)
                                ||prdTypCd.startsWith(InsuranceConstant.CODE_PRD_TYP_CD_015)){
                            //挂车 不用上传交强险保单
                            mav.addObject("isTrailer",BaseConstant.IS_YESNO_YES);
                        }
                    }
                }
            }
        }
        mav.addObject("ctrlKey","1");//控制保单附件维护 1.可上传删除 2.审核
        return mav;
    }

    /**
     * 到详情页面
     */
    @RequestMapping(value = "/toDetailPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toDetailPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toDetailPage", "加载InsPlcBscInfo Detail页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("insurance/insPlcBscInfo/insPlcBscInfoDetail");
        String id = request.getParameter("id");
        String colseFlag = request.getParameter("colseFlag");//详情页面是否可关闭
        String prjId = request.getParameter("prjId");
        String paySchNo = request.getParameter("paySchNo");
        GetInsPlcBscInfoRequest getRequest = new GetInsPlcBscInfoRequest();
        getRequest.setId(Long.valueOf(id));
        ResponseData responseData = iInsPlcBscInfoService.selectById(getRequest);
        BaseLogUtils.info(logger, "deleteInsPlcBscInfos", "贷前--获取InsPlcBscInfo数据，request:" +
                JSONObject.toJSONString(getRequest) + ",response:" + JSONObject.toJSONString(responseData), CurrentThreadContext.getCurrentUserName());
        InsPlcBscInfoVO insPlcBscInfoVO = null;
        if (responseData != null && responseData.getData() != null) {
            InsPlcBscInfoDTO dto = (InsPlcBscInfoDTO) responseData.getData();
            insPlcBscInfoVO = new InsPlcBscInfoVO();
            BeanUtils.copyProperties(dto,insPlcBscInfoVO);
        }
        //InsPlcBscInfoVO insPlcBscInfoVO = this.insPlcBscInfoService.selectById(Long.valueOf(id));
        if (insPlcBscInfoVO.getPlcBgTm() != null) {
            insPlcBscInfoVO.setPlcBgTms(DateUtils.formatDateToString(insPlcBscInfoVO.getPlcBgTm(), DateUtils.YYYY_MM_DD));
        }
        if (insPlcBscInfoVO.getPlcEndTm() != null) {
            insPlcBscInfoVO.setPlcEndTms(DateUtils.formatDateToString(insPlcBscInfoVO.getPlcEndTm(), DateUtils.YYYY_MM_DD));
        }
        if (insPlcBscInfoVO.getInsTtlFee() != null) {
            insPlcBscInfoVO.setInsTtlFeeDb(DecimalUtils.convertFenToYuan(insPlcBscInfoVO.getInsTtlFee()));
        }
        if (insPlcBscInfoVO.getPrjId() == null&&StringUtils.isNotEmpty(prjId)) {
            insPlcBscInfoVO.setPrjId(Long.valueOf(prjId));
        }
        mav.addObject("insPlcBscInfoVO", insPlcBscInfoVO);
        mav.addObject("colseFlag", colseFlag);
        mav.addObject("prjId", prjId);
        mav.addObject("paySchNo", paySchNo);
        return mav;
    }


    /**
     * 到保单核查页面
     */
    @RequestMapping(value = "/toCheckPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toPlcCheckPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toPlcCheckPage", "加载到保单核查页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("insurance/insPlcBscInfo/insPlcBscInfoCheck");
        String id = request.getParameter("id");//保单ID
        String saveFlag = request.getParameter("saveFlag");//是否显示保存处理方式按钮：1显示 其他值不显示
        String bkFlag = request.getParameter("bkFlag");//是否显示收款账号信息：1.显示 2.维护 其他值不显示
        mav.addObject("saveFlag", saveFlag);
        mav.addObject("bkFlag", bkFlag);
        GetInsPlcBscInfoRequest getRequest = new GetInsPlcBscInfoRequest();
        getRequest.setId(Long.valueOf(id));
        ResponseData responseData = iInsPlcBscInfoService.selectById(getRequest);
        BaseLogUtils.info(logger, "deleteInsPlcBscInfos", "贷前--获取InsPlcBscInfo数据，request:" +
                JSONObject.toJSONString(getRequest) + ",response:" + JSONObject.toJSONString(responseData), CurrentThreadContext.getCurrentUserName());
        InsPlcBscInfoVO insPlcBscInfoVO = null;
        if (responseData != null && responseData.getData() != null) {
            InsPlcBscInfoDTO dto = (InsPlcBscInfoDTO) responseData.getData();
            insPlcBscInfoVO = new InsPlcBscInfoVO();
            BeanUtils.copyProperties(dto,insPlcBscInfoVO);
        }
        //InsPlcBscInfoVO insPlcBscInfoVO = this.insPlcBscInfoService.selectById(Long.valueOf(id));
        if (insPlcBscInfoVO.getPlcBgTm() != null) {
            insPlcBscInfoVO.setPlcBgTms(DateUtils.formatDateToString(insPlcBscInfoVO.getPlcBgTm(), DateUtils.YYYY_MM_DD));
        }
        if (insPlcBscInfoVO.getPlcEndTm() != null) {
            insPlcBscInfoVO.setPlcEndTms(DateUtils.formatDateToString(insPlcBscInfoVO.getPlcEndTm(), DateUtils.YYYY_MM_DD));
        }
        if (insPlcBscInfoVO.getInsTtlFee() != null) {
            insPlcBscInfoVO.setInsTtlFeeDb(DecimalUtils.convertFenToYuan(insPlcBscInfoVO.getInsTtlFee()));
        }

        //查询历史保单
        //InsPlcBscInfoQueryCondition condition = new InsPlcBscInfoQueryCondition();
        cn.fl.preloan.condition.InsPlcBscInfoQueryCondition condition = new cn.fl.preloan.condition.InsPlcBscInfoQueryCondition();
        condition.setPaySchId(insPlcBscInfoVO.getPaySchId());
        condition.setInsTypCd(insPlcBscInfoVO.getInsTypCd());
        GetInsPlcBscInfoListRequest getListRequest = new GetInsPlcBscInfoListRequest(condition);
        getListRequest.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
        getListRequest.setSysCd(CurrentThreadContext.getCurrentSysCd());
        BaseLogUtils.info(logger, "searchList", "贷前--获取保单数据，request:" + JSONObject.toJSONString(getListRequest), CurrentThreadContext.getCurrentUserName());
        ResponseData infoResponse = iInsPlcBscInfoService.searchList(getListRequest);
        BaseLogUtils.info(logger, "searchList", "贷前--获取保单数据,response:" + JSONObject.toJSONString(infoResponse), CurrentThreadContext.getCurrentUserName());
        //List<InsPlcBscInfoVO> voList = this.insPlcBscInfoService.searchList(condition);
        List<InsPlcBscInfoDTO> list = null;
        List<InsPlcBscInfoVO> voList = new ArrayList<>();
        if (infoResponse != null && infoResponse.getData() != null){
            list = (List<InsPlcBscInfoDTO>) infoResponse.getData();
            InsPlcBscInfoVO infoVO = null;
            for (InsPlcBscInfoDTO insPlcBscInfoDTO : list) {
                infoVO = new InsPlcBscInfoVO();
                BeanUtils.copyProperties(insPlcBscInfoDTO,infoVO);
                voList.add(infoVO);
            }
        }
        if (CollectionUtils.isNotEmpty(voList)) {
            List<KeyValueVO> hisPlcList = new ArrayList<>(voList.size());
            KeyValueVO kv = null;
            for (InsPlcBscInfoVO vo : voList) {
                if (insPlcBscInfoVO.getId().equals(vo.getId())) {
                    continue;
                }
                kv = new KeyValueVO();
                kv.setKey("" + vo.getId());
                kv.setValue(vo.getPlcNo());
                hisPlcList.add(kv);
            }
            mav.addObject("hisPlcList", hisPlcList);
        }

        //查询支付表保险保证金
        PrjPrdPaySchDQueryCondition qc = new PrjPrdPaySchDQueryCondition();
        qc.setPaySchId(insPlcBscInfoVO.getPaySchId());
        qc.setFeeTypCd(InsuranceConstant.CODE_FEE_TYP_CD_11);//保险保证金
        List<PrjPrdPaySchDVO> dtlList = prjPrdPaySchDService.searchList(qc);
        if (CollectionUtils.isNotEmpty(dtlList)) {
            PrjPrdPaySchDVO paySchDVO = dtlList.get(0);
            mav.addObject("feeAmt", DecimalUtils.convertFenToYuan(paySchDVO.getFeeAmt().longValue()));
            mav.addObject("paySchDVO", paySchDVO);

            //查询保险保证金的处理方式
            CapFeeOutLogQueryCondition logQueryCondition = new CapFeeOutLogQueryCondition();
            logQueryCondition.setPaySchId(insPlcBscInfoVO.getPaySchId());
            logQueryCondition.setPaySchDId(paySchDVO.getId());
            logQueryCondition.setFeeTypCd(InsuranceConstant.CODE_FEE_TYP_CD_11);
            List<CapFeeOutLogVO> logList = this.capFeeOutLogService.searchList(logQueryCondition);
            if (CollectionUtils.isNotEmpty(logList)) {
                CapFeeOutLogVO logVO = logList.get(0);
                insPlcBscInfoVO.setHandleWayCd(logVO.getHandleWayCd());
                mav.addObject("feeSts", logVO.getHandleWayCdNm());
                /*if (StringUtils.isNotEmpty(logVO.getBizDataId()) && logVO.getBizDataId().equals(insPlcBscInfoVO.getId())) {
                    mav.addObject("feeSts", "正常");
                } else {
                    mav.addObject("feeSts", logVO.getHandleWayCdNm());
                }*/
            } else {
                mav.addObject("feeSts", "正常");
            }
        } else {
            mav.addObject("feeAmt", "0.00");
            mav.addObject("feeSts", "无保险保证金信息");
        }
        mav.addObject("insPlcBscInfoVO", insPlcBscInfoVO);

        List<KeyValueVO> handleWayCdList = this.capFeeOutLogService.searchDictListByGrpCd(CapitalConstant.CODE_HANDLE_WAY_CD);
        //保单选择一次性渠道并且返利性质为续保保证金冲抵时，保险保证金的处理方式只能扣除
        if (StringUtils.isNotEmpty(insPlcBscInfoVO.getChnPol())) {
            InsCompChnPolVO polVO = this.insCompChnPolService.selectById(insPlcBscInfoVO.getChnPol());
            if (InsuranceConstant.CODE_INS_COMP_REB_NAT_CD_2.equals(polVO.getRebNatCd())) {//续保保证金冲抵
                insPlcBscInfoVO.setHandleWayCd(CapitalConstant.CODE_HANDLE_WAY_CD_4);
                Iterator<KeyValueVO> iterator = handleWayCdList.iterator();
                while(iterator.hasNext()){
                    KeyValueVO kv = iterator.next();
                    if(!CapitalConstant.CODE_HANDLE_WAY_CD_4.equals(kv.getKey())){
                        iterator.remove();
                    }
                }
            }
        }
        if (CollectionUtils.isNotEmpty(handleWayCdList)) {
            mav.addObject("handleWayCdList", JSON.toJSONString(handleWayCdList));
        }
        return mav;
    }

    /**
     * 到保险列表页面
     */
    @RequestMapping(value = "/toPlcListPage.do", method = {RequestMethod.GET})
    public ModelAndView toDtlListPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toListPage", "到保险列表页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("insurance/insPlcBscInfo/insPlcDtlList");
        String paySchId = request.getParameter("paySchId");
        mav.addObject("paySchId", paySchId);//支付表ID
        return mav;
    }

    private void prepare(HttpServletRequest request, ModelAndView mav) {
        //加载数据字典数据、传值等 ？
        List<KeyValueVO> insTypCdList=this.insPlcBscInfoService.searchInsTypCdList();//保险种类
        List<KeyValueVO> buyWayCdList = this.insPlcBscInfoService.searchBuyWayCdList();//购买方式
        List<KeyValueVO> plcExpCdList = this.insPlcBscInfoService.searchPlcExpCdList();//保单期限
        List<KeyValueVO> prdTypCdList = this.insPlcBscInfoService.searchPrdTypCdList();//保单产品类型
        List<KeyValueVO> fstPerTypCdList = this.insPlcBscInfoService.searchInsFstPerTypCdList();//保单第一受益人
        mav.addObject("insTypCdList", JSON.toJSONString(insTypCdList));
        mav.addObject("buyWayCdList", JSON.toJSONString(buyWayCdList));
        mav.addObject("plcExpCdList", JSON.toJSONString(plcExpCdList));
        mav.addObject("prdTypCdList", JSON.toJSONString(prdTypCdList));
        mav.addObject("fstPerTypCdList", JSON.toJSONString(fstPerTypCdList));
        List<KeyValueVO> plcPropCdList = this.insPlcBscInfoService.searchPlcPropCdList();//保单性质
        mav.addObject("plcPropCdList", JSON.toJSONString(plcPropCdList));
        //保险公司
        InsCompInfoQueryCondition qc = new InsCompInfoQueryCondition();
        qc.setCompLvl(1);
        List<InsCompInfoDTO> insCompList = this.insCompInfoService.searchList(qc);
        if (CollectionUtils.isNotEmpty(insCompList)) {
            List<KeyValueVO> compList = new ArrayList<>(insCompList.size());
            KeyValueVO vo = null;
            for (InsCompInfoDTO dto : insCompList) {
                vo = new KeyValueVO();
                vo.setKey(dto.getId().toString());
                vo.setValue(dto.getCompNm());
                compList.add(vo);
            }
            mav.addObject("insCompList", JSON.toJSONString(compList));
        }
    }

    /**
     * 初始化列表
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/initList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initInsPlcBscInfoList(HttpServletRequest request, HttpServletResponse response) {
        String currentPage = request.getParameter("page");
        String pageSize = request.getParameter("pagesize");
        Pager page = new Pager();
        if (StringUtils.isNotEmpty(currentPage)) {
            page.setCurrentPage(Integer.parseInt(currentPage));
        }

        if (StringUtils.isNotEmpty(pageSize)) {
            page.setEveryPage(Integer.parseInt(pageSize));
        }
        cn.fl.preloan.condition.InsPlcBscInfoQueryCondition qc = new cn.fl.preloan.condition.InsPlcBscInfoQueryCondition();
        //InsPlcBscInfoQueryCondition qc = new InsPlcBscInfoQueryCondition();
        //设置查询条件？
        String plcNo = request.getParameter("plcNo");//保单号
        String insCompNm = request.getParameter("insCompNm");//保险公司名称
        String paySchNo = request.getParameter("paySchNo");//支付表号
        String cstNm = request.getParameter("cstNm");
        String cstMgrNm = request.getParameter("cstMgrNm");
        String insCompId = request.getParameter("insCompId");
        String plcEndTmMin = request.getParameter("plcEndTmMin");
        String plcEndTmMax = request.getParameter("plcEndTmMax");
        String plcBgTmStart = request.getParameter("plcBgTmStart");
        String plcBgTmEnd = request.getParameter("plcBgTmEnd");
        String prjId = request.getParameter("prjId");
        String prjPrdDtlId = request.getParameter("prjPrdDtlId");

        if (StringUtils.isNotBlank(plcNo)) {
            qc.setPlcNo(plcNo);
        }
        if (StringUtils.isNotBlank(insCompNm)) {
            qc.setInsCompNm(insCompNm);
        }
        if (StringUtils.isNotBlank(paySchNo)) {
            qc.setPaySchNo(paySchNo);
        }
        if (StringUtils.isNotBlank(cstNm)) {
            qc.setCstNm(cstNm);
        }
        if (StringUtils.isNotBlank(cstMgrNm)) {
            qc.setCstMgrNm(cstMgrNm);
        }
        if (StringUtils.isNotEmpty(insCompId)) {
            qc.setInsCompId(Long.valueOf(insCompId));
        }
        if(StringUtils.isNotEmpty(plcEndTmMin)){
            qc.setPlcEndTmMin(plcEndTmMin);
        }
        if(StringUtils.isNotEmpty(plcEndTmMax)){
            qc.setPlcEndTmMax(plcEndTmMax);
        }
        if(StringUtils.isNotEmpty(plcBgTmStart)){
            qc.setPlcBgTmStart(plcBgTmStart);
        }
        if(StringUtils.isNotEmpty(plcBgTmEnd)){
            qc.setPlcBgTmEnd(plcBgTmEnd);
        }
        if(StringUtils.isNotEmpty(prjId)){
            qc.setPrjId(Long.valueOf(prjId));
        }
        if(StringUtils.isNotEmpty(prjPrdDtlId)){
            qc.setPrjPrdDtlId(Long.valueOf(prjPrdDtlId));
        }

        qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
        qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
        qc.setUsrId(CurrentThreadContext.getCurrentUserId());
        //page.setCondition(qc);

        ResponseData responseData = iInsPlcBscInfoService.searchListPageByCondition(page.getEveryPage(), page.getCurrentPage(), qc,
                CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
        BaseLogUtils.info(logger, "initInsPlcBscInfoList", "贷前--初始化保单管理列表页面数据.request:" +
                JSONObject.toJSONString(qc) + ",response: " + JSONObject.toJSONString(responseData), CurrentThreadContext.getCurrentUserName());
        PageResponse<InsPlcBscInfoDTO> pageResponse = null;
        List<InsPlcBscInfoVO> list = new ArrayList<>();
        InsPlcBscInfoVO insPlcBscInfoVO = null;
        if (responseData != null && responseData.getData() != null) {
            pageResponse = (PageResponse<InsPlcBscInfoDTO>) responseData.getData();
            List<InsPlcBscInfoDTO> insPlcBscInfoDTOList = pageResponse.getList();
            for (InsPlcBscInfoDTO insPlcBscInfoDTO : insPlcBscInfoDTOList) {
                insPlcBscInfoVO = new InsPlcBscInfoVO();
                BeanUtils.copyProperties(insPlcBscInfoDTO,insPlcBscInfoVO);
                list.add(insPlcBscInfoVO);
            }
        }
        /*Pager pager = this.insPlcBscInfoService.searchListPage(page);
        List<InsPlcBscInfoVO> list = (List<InsPlcBscInfoVO>) pager.getResultList();*/
        ListPageVO<InsPlcBscInfoVO> listPage = new ListPageVO<InsPlcBscInfoVO>(list, pageResponse.getTotalCount());
        BaseLogUtils.info(logger, "initInsPlcBscInfoList", "贷前--初始化保单管理列表页面数据.listPage:" +
                JSONObject.toJSONString(listPage) , CurrentThreadContext.getCurrentUserName());        return listPage;
    }

    /**
     * 保险产品列表
     * @param request
     * @return
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/initPlcPrdList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initInsPlcBscInfoList(HttpServletRequest request) {
        String prjPrdDtlId = request.getParameter("prjPrdDtlId");//项目产品明细ID
        String prjId = request.getParameter("prjId");//项目ID
        if(StringUtils.isEmpty(prjPrdDtlId)){
            return null;
        }
        //查询项目产品明细信息
        PrjPrdDtlForInsQueryCondition qc = new PrjPrdDtlForInsQueryCondition();
        qc.setId(Long.valueOf(prjPrdDtlId));
        qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
        qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
        List<PrjPrdDtlForInsDTO> prdList = this.insPlcBscInfoService.searchInsurePrdList(qc);
        ListPageVO<PrjPrdDtlForInsDTO> listPage = null;
        if(CollectionUtils.isNotEmpty(prdList)){
            //换车-绑定项目之前的页面渲染
            String cstNm = prdList.get(0).getCstNm();
            if (StringUtils.isEmpty(cstNm) && StringUtils.isNotEmpty(prjId)) {
                PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(Long.valueOf(prjId));
                if (prjBscInfoVO != null) {
                    for (PrjPrdDtlForInsDTO prjPrdDtlForInsDTO : prdList) {
                        prjPrdDtlForInsDTO.setCstNm(prjBscInfoVO.getCstNm());
                    }
                }
            }
            listPage = new ListPageVO<PrjPrdDtlForInsDTO>(prdList, prdList.size());
        }else{
            listPage = new ListPageVO<PrjPrdDtlForInsDTO>(null, 0);
        }
        return listPage;
    }

    /**
     * 删除数据
     */
    @RequestMapping(value = "/removeByIds.do", method = {RequestMethod.POST})
    @ResponseBody
    public DataResultVO removeInsPlcBscInfoByIds(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String ids = request.getParameter("ids");
        String paySchId = request.getParameter("paySchId");
        String prjPrdDtlId = request.getParameter("prjPrdDtlId");
        String prjPrdChangeFlag = request.getParameter("prjPrdChangeFlag");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
        if (StringUtils.isEmpty(ids)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            BaseLogUtils.info(logger, "removeInsPlcBscInfoByIds", "删除InsPlcBscInfo数据,主键参数为空!", CurrentThreadContext.getCurrentUserName());
            return result;
        }
        if (StringUtils.isEmpty(paySchId) && !"true".equals(prjPrdChangeFlag)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            BaseLogUtils.info(logger, "removeInsPlcBscInfoByIds", "删除InsPlcBscInfo数据校验,支付表id为空!", CurrentThreadContext.getCurrentUserName());
            return result;
        }
        if (StringUtils.isEmpty(prjPrdDtlId)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            BaseLogUtils.info(logger, "removeInsPlcBscInfoByIds", "删除InsPlcBscInfo数据校验，产品id为空!", CurrentThreadContext.getCurrentUserName());
            return result;
        }
        List<Long> idsList = new ArrayList<Long>();
        JSONArray idsArray = JSONArray.fromObject(ids);
        for (Object object : idsArray) {
            idsList.add(Long.valueOf(object.toString()));
        }

        try {
            //引入贷前服务--批量删除保单数据
            DeleteInsPlcBscInfoRequest deleteRequest = new DeleteInsPlcBscInfoRequest();
            deleteRequest.setIds(idsList);
            deleteRequest.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
            BaseLogUtils.info(logger, "deleteInsPlcBscInfos", "贷前--删除InsPlcBscInfo数据，request:" + JSONObject.toJSONString(deleteRequest), CurrentThreadContext.getCurrentUserName());
            ResponseData responseData = iInsPlcBscInfoService.deleteInsPlcBscInfos(deleteRequest);
            BaseLogUtils.info(logger, "deleteInsPlcBscInfos", "贷前--删除InsPlcBscInfo数据,response:" + JSONObject.toJSONString(responseData), CurrentThreadContext.getCurrentUserName());
            //boolean success = this.insPlcBscInfoService.removeByIds(idsList);
            if (responseData.getCode().equals(ResponseData.FAIL_CODE)) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_DELETE_FAIL);
                BaseLogUtils.info(logger, "removeInsPlcBscInfoByIds", "删除InsPlcBscInfo数据失败,ID:" + idsList.toString(), CurrentThreadContext.getCurrentUserName());
            }
            //若产品所有保单都被删除，则更新产品为“未投保”
            cn.fl.preloan.condition.InsPlcBscInfoQueryCondition condition = new cn.fl.preloan.condition.InsPlcBscInfoQueryCondition();
            if ("true".equals(prjPrdChangeFlag)) {
                condition.setPrjPrdDtlId(Long.valueOf(prjPrdDtlId));
            } else {
                condition.setPaySchId(Long.valueOf(paySchId));
            }
            condition.setIsDel(0);
            GetInsPlcBscInfoListRequest getListRequest = new GetInsPlcBscInfoListRequest(condition);
            getListRequest.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
            getListRequest.setSysCd(CurrentThreadContext.getCurrentSysCd());
            BaseLogUtils.info(logger, "searchList", "贷前--获取保单数据，request:" + JSONObject.toJSONString(getListRequest), CurrentThreadContext.getCurrentUserName());
            ResponseData infoResponse = iInsPlcBscInfoService.searchList(getListRequest);
            BaseLogUtils.info(logger, "searchList", "贷前--获取保单数据,response:" + JSONObject.toJSONString(infoResponse), CurrentThreadContext.getCurrentUserName());
            List<InsPlcBscInfoDTO> plcBscInfoDTOList = (List<InsPlcBscInfoDTO>) infoResponse.getData();
            if (CollectionUtils.isEmpty(plcBscInfoDTOList)){
                List<Long> prdIdList = new ArrayList<Long>();
                prdIdList.add(Long.valueOf(prjPrdDtlId));
                int i = this.projectApiService.updatePrjPrdDtlInsStsCd(prdIdList, InsuranceConstant.CODE_INS_PRD_STS_CD_10);
                BaseLogUtils.newLogger("更新投保状态prdId="+prjPrdDtlId +"为未投保：" + i).info();
            }
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.info(logger, "removeInsPlcBscInfoByIds", "删除InsPlcBscInfo数据失败,ID:" + idsList.toString() + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.error(logger, "removeInsPlcBscInfoByIds", "删除InsPlcBscInfo数据失败,系统错误.ID:" + idsList.toString() + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }

    /**
     * 得到一条记录
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getById.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object getInsPlcBscInfoById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String id = request.getParameter("id");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
        if (StringUtils.isEmpty(id)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            BaseLogUtils.info(logger, "getInsPlcBscInfoById", "获取InsPlcBscInfo数据,主键参数为空.", CurrentThreadContext.getCurrentUserName());
            return result;
        }

        try {
            GetInsPlcBscInfoRequest getRequest = new GetInsPlcBscInfoRequest();
            getRequest.setId(Long.valueOf(id));
            ResponseData responseData = iInsPlcBscInfoService.selectById(getRequest);
            BaseLogUtils.info(logger, "deleteInsPlcBscInfos", "贷前--获取InsPlcBscInfo数据，request:" +
                    JSONObject.toJSONString(getRequest) + ",response:" + JSONObject.toJSONString(responseData), CurrentThreadContext.getCurrentUserName());
            //InsPlcBscInfoVO vo = this.insPlcBscInfoService.selectById(Long.valueOf(id));
            if (responseData.getData() == null) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
                BaseLogUtils.info(logger, "getInsPlcBscInfoById", "贷前--获取InsPlcBscInfo数据不存在,ID:" + id, CurrentThreadContext.getCurrentUserName());
            }
            result.setData(responseData.getData());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.info(logger, "getInsPlcBscInfoById", "获取InsPlcBscInfo数据失败,ID:" + id + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.error(logger, "getInsPlcBscInfoById", "获取InsPlcBscInfo数据失败,系统错误.ID:" + id + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }

    /**
     * 新增保单
     */
    @RequestMapping(value = "/add.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object addInsPlcBscInfo(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
        InsPlcBscInfoVO entity = null;//获取参数
        try {
            entity = this.getRequestParamForInsPlcBscInfo(request);//获取参数
            //引入贷前服务
            AddInsPlcBscInfoRequest addInsPlcBscInfoRequest = new AddInsPlcBscInfoRequest();
            InsPlcBscInfoDTO insPlcBscInfoDTO = new InsPlcBscInfoDTO();
            BeanUtils.copyProperties(entity,insPlcBscInfoDTO);
            addInsPlcBscInfoRequest.setInsPlcBscInfoDTO(insPlcBscInfoDTO);
            //保单产品
            List<cn.fl.preloan.dto.insurance.InsPlcPrdDtlTkDTO> tkDTOS = new ArrayList<>();
            cn.fl.preloan.dto.insurance.InsPlcPrdDtlTkDTO tkDTO = null;
            if (entity.getInsPlcPrdDtlTkVOList() != null) {
                for (InsPlcPrdDtlTkVO insPlcPrdDtlTkVO : entity.getInsPlcPrdDtlTkVOList()) {
                    tkDTO = new cn.fl.preloan.dto.insurance.InsPlcPrdDtlTkDTO();
                    BeanUtils.copyProperties(insPlcPrdDtlTkVO,tkDTO);
                    tkDTOS.add(tkDTO);
                }
                addInsPlcBscInfoRequest.setPrdDtlTkDTOList(tkDTOS);
            }

            //保单险种
            List<InsPlcTypDtlDTO> typDtlDTOS = new ArrayList<>();
            InsPlcTypDtlDTO typDtlDTO = null;
            if (entity.getInsPlcTypDtlVOList() != null) {
                for (InsPlcTypDtlVO insPlcTypDtlVO : entity.getInsPlcTypDtlVOList()) {
                    typDtlDTO = new InsPlcTypDtlDTO();
                    BeanUtils.copyProperties(insPlcTypDtlVO,typDtlDTO);
                    typDtlDTOS.add(typDtlDTO);
                }
                addInsPlcBscInfoRequest.setTypDtlDTOList(typDtlDTOS);
            }
            //附件信息
            List<SysUlFilesRecDTO> sysUlFilesRecDTOS = SysUlFilesRecVOTransform.toDTOList(entity.getSysUlFilesRecVOList());
            addInsPlcBscInfoRequest.setSysUlFilesRecDTOList(sysUlFilesRecDTOS);

            ResponseData responseData = iInsPlcBscInfoService.addInsPlcBscInfo(addInsPlcBscInfoRequest);
            /*Long id = this.insPlcBscInfoService.add(entity);
            result.setData(id);*/
            Long i = (Long) responseData.getData();
            result.setData(i);
            BaseLogUtils.info(logger, "addInsPlcBscInfo", "贷前服务--新增InsPlcBscInfo数据.DATA:" + JSONObject.toJSONString(entity) + "结果id:" + i, CurrentThreadContext.getCurrentUserName());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR + ex.getMessage());
            BaseLogUtils.info(logger, "addInsPlcBscInfo", "新增InsPlcBscInfo数据失败.DATA:" + JSONObject.toJSONString(entity) + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR + ex.getMessage());
            BaseLogUtils.error(logger, "addInsPlcBscInfo", "新增InsPlcBscInfo数据失败,系统错误.DATA:" + JSONObject.toJSONString(entity) + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/modify.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object modifyInsPlcBscInfo(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
        InsPlcBscInfoVO entity = null;
        try {
            entity = this.getRequestParamForInsPlcBscInfo(request);
            if (entity.getId() == null) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
                BaseLogUtils.info(logger, "modifyInsPlcBscInfo", "修改InsPlcBscInfo信息,主键参数为空！.ID:" + entity.getId(), CurrentThreadContext.getCurrentUserName());
                return result;
            }

            //接入贷前服务
            ModifyInsPlcBscInfoRequest modifyRequest = new ModifyInsPlcBscInfoRequest();
            InsPlcBscInfoDTO insPlcBscInfoDTO = new InsPlcBscInfoDTO();
            insPlcBscInfoDTO.setId(entity.getId());
            BeanUtils.copyProperties(entity,insPlcBscInfoDTO);
            modifyRequest.setInsPlcBscInfoDTO(insPlcBscInfoDTO);
            List<InsPlcTypDtlDTO> insPlcTypDtlDTOS = new ArrayList<>();
            InsPlcTypDtlDTO insPlcTypDtlDTO = null;
            if (entity.getInsPlcTypDtlVOList() != null) {
                for (InsPlcTypDtlVO insPlcTypDtlVO : entity.getInsPlcTypDtlVOList()) {
                    insPlcTypDtlDTO = new InsPlcTypDtlDTO();
                    insPlcTypDtlDTO.setId(insPlcTypDtlVO.getId());
                    BeanUtils.copyProperties(insPlcTypDtlVO,insPlcTypDtlDTO);
                    insPlcTypDtlDTOS.add(insPlcTypDtlDTO);
                }
                modifyRequest.setInsPlcTypDtlDTOS(insPlcTypDtlDTOS);
            }
            //附件信息
            List<SysUlFilesRecDTO> sysUlFilesRecDTOS = SysUlFilesRecVOTransform.toDTOList(entity.getSysUlFilesRecVOList());
            modifyRequest.setSysUlFilesRecDTOList(sysUlFilesRecDTOS);
            ResponseData responseData = iInsPlcBscInfoService.modifyInsPlcBscInfo(modifyRequest);
            BaseLogUtils.info(logger, "modifyInsPlcBscInfo", "贷前--修改InsPlcBscInfo数据.request:" + JSONObject.toJSONString(modifyRequest)
                    + ",response: " + responseData, CurrentThreadContext.getCurrentUserName());
            /*boolean success = this.insPlcBscInfoService.modify(entity);*/
            if (responseData.getCode().equals(ResponseData.FAIL_CODE)) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_UPDATE_FAIL);
                BaseLogUtils.info(logger, "modifyInsPlcBscInfo", "修改InsPlcBscInfo数据失败.DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
                return result;
            }
            BaseLogUtils.info(logger, "modifyInsPlcBscInfo", "修改InsPlcBscInfo数据成功.DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR + ex.getMessage());
            BaseLogUtils.info(logger, "modifyInsPlcBscInfo", "修改InsPlcBscInfo数据失败.DATA:" + JSONObject.toJSONString(entity) + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR + ex.getMessage());
            BaseLogUtils.error(logger, "modifyInsPlcBscInfo", "修改InsPlcBscInfo数据失败,系统错误.DATA:" + JSONObject.toJSONString(entity) + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }

    /**
     * 修改计不计入续保状态
     */
    @RequestMapping(value = "/modifyRenewCd.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object modifyRenewCd(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String ids = request.getParameter("ids");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
        if (StringUtils.isEmpty(ids)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            BaseLogUtils.info(logger, "modifyRenewCd", "修改计不计入续保状态,主键参数为空!", CurrentThreadContext.getCurrentUserName());
            return result;
        }

        try {
            ModifyInsPlcBscInfoListRequest modifyRequest = new ModifyInsPlcBscInfoListRequest();
            List<InsPlcBscInfoDTO> insPlcBscInfoDTOS = new ArrayList<>();
            JSONArray idsArray = JSONArray.fromObject(ids);
            for (Object object : idsArray) {
                net.sf.json.JSONObject jsonObject = (net.sf.json.JSONObject) object;
                InsPlcBscInfoDTO dto = new InsPlcBscInfoDTO();
                dto.setId(Long.valueOf(String.valueOf(jsonObject.get("id"))));
                dto.setIsRene(Integer.valueOf(String.valueOf(jsonObject.get("isRene"))));
                insPlcBscInfoDTOS.add(dto);
            }
            modifyRequest.setList(insPlcBscInfoDTOS);
            BaseLogUtils.info(logger, "modifyRenewCd", "贷前--修改计不计入续保状态，request：" + JSONObject.toJSONString(modifyRequest), CurrentThreadContext.getCurrentUserName());
            ResponseData responseData = iInsPlcBscInfoService.modifyInsPlcBscInfo(modifyRequest);
            BaseLogUtils.info(logger, "modifyRenewCd", "贷前--修改计不计入续保状态，response：" + JSONObject.toJSONString(responseData), CurrentThreadContext.getCurrentUserName());
            /*boolean success = this.insPlcBscInfoService.modify(voList);*/
            if (responseData.getCode().equals(ResponseData.FAIL_CODE)) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_OPERATE_FAIL);
                BaseLogUtils.info(logger, "modifyRenewCd", "修改计不计入续保状态失败,ID:" + ids, CurrentThreadContext.getCurrentUserName());
            }
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.info(logger, "modifyRenewCd", "修改计不计入续保状态失败,ID:" + ids + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.error(logger, "modifyRenewCd", "修改计不计入续保状态失败,系统错误.ID:" + ids + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }

    /**
     * 初始化列表
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/initPlcList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initInsPlcDtlList(HttpServletRequest request, HttpServletResponse response) {
        //InsPlcBscInfoQueryCondition qc = new InsPlcBscInfoQueryCondition();
        //设置查询条件？
        cn.fl.preloan.condition.InsPlcBscInfoQueryCondition qc = new cn.fl.preloan.condition.InsPlcBscInfoQueryCondition();
        String paySchId = request.getParameter("paySchId");
        if (StringUtils.isNotBlank(paySchId)) {
            qc.setPaySchId(Long.valueOf(paySchId));
        }
        BaseLogUtils.info(logger, "initInsPlcDtlList", "初始化保单列表页面数据.DATA:" + JSONObject.toJSONString(qc), CurrentThreadContext.getCurrentUserName());
        GetInsPlcBscInfoListRequest getListRequest = new GetInsPlcBscInfoListRequest(qc);
        getListRequest.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
        getListRequest.setSysCd(CurrentThreadContext.getCurrentSysCd());
        BaseLogUtils.info(logger, "initInsPlcDtlList", "贷前--获取保单数据，request:" + JSONObject.toJSONString(getListRequest), CurrentThreadContext.getCurrentUserName());
        ResponseData infoResponse = iInsPlcBscInfoService.searchList(getListRequest);
        BaseLogUtils.info(logger, "initInsPlcDtlList", "贷前--获取保单数据,response:" + JSONObject.toJSONString(infoResponse), CurrentThreadContext.getCurrentUserName());
        //List<InsPlcBscInfoVO> voList = this.insPlcBscInfoService.searchList(condition);
        List<InsPlcBscInfoDTO> list = null;
        List<InsPlcBscInfoVO> voList = new ArrayList<>();
        if (infoResponse != null && infoResponse.getData() != null){
            list = (List<InsPlcBscInfoDTO>) infoResponse.getData();
            InsPlcBscInfoVO infoVO = null;
            for (InsPlcBscInfoDTO insPlcBscInfoDTO : list) {
                infoVO = new InsPlcBscInfoVO();
                BeanUtils.copyProperties(insPlcBscInfoDTO,infoVO);
                voList.add(infoVO);
            }
        }

        //List<InsPlcBscInfoVO> list = this.insPlcBscInfoService.searchList(qc);
        ListPageVO<InsPlcBscInfoVO> listPage = null;
        if (CollectionUtils.isNotEmpty(list)) {
            listPage = new ListPageVO<InsPlcBscInfoVO>(voList, voList.size());
        }
        return listPage;
    }

    /**
     * 验证保单号是否唯一
     *
     * @param request
     * @param response
     * @return
     * @throws BaseException
     */
    @RequestMapping(value = "/validatePlcNo.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object validatePlcNo(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "查询成功");
        String plcNo = request.getParameter("plcNo");//保单号
        if (StringUtils.isEmpty(plcNo)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("查询失败，保单号为空");
            return result;
        }
        BaseLogUtils.info(logger, "validatePlcNo", "验证保单号是否唯一：" + plcNo, CurrentThreadContext.getCurrentUserName());
        GetInsPlcBscInfoByPlcNoRequest plcNoRequest = new GetInsPlcBscInfoByPlcNoRequest();
        plcNoRequest.setPlcNo(plcNo);
        ResponseData responseData = iInsPlcBscInfoService.validatePlcNo(plcNoRequest);
        result.setData(responseData.getData());
        BaseLogUtils.info(logger, "validatePlcNo", "贷前--验证保单号是否唯一：" + JSONObject.toJSONString(responseData), CurrentThreadContext.getCurrentUserName());
        return result;
    }

    /**
     * 验证保险公司是否设置渠道信息
     *
     * @param request
     * @param response
     * @return
     * @throws BaseException
     */
    @RequestMapping(value = "/validateInsComp.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object validateInsComp(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "查询成功");
        String insCompId = request.getParameter("insCompId");//保险子公司Id
        String prdTypCd = request.getParameter("prdTypCd");//保险产品类型
        String insTypCd = request.getParameter("insTypCd");//保险种类
        if (StringUtils.isEmpty(insCompId)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("查询失败，保险公司ID为空");
            return result;
        }
        BaseLogUtils.info(logger, "validateInsComp", "验证保险公司是否设置渠道信息：" + insCompId + "," + prdTypCd, CurrentThreadContext.getCurrentUserName());
        result.setData(this.insPlcBscInfoService.validateInsComp(Long.valueOf(insCompId), prdTypCd, insTypCd));
        return result;
    }

    /**
     * 验证项目产品对应的保险险种是否已录入
     *
     * @param request
     * @param response
     * @return
     * @throws BaseException
     */
    @RequestMapping(value = "/validateInsTyp.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object validateInsTyp(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "查询成功");
        String prjPrdDtlId = request.getParameter("prjPrdDtlId");//项目产品明细ID
        String insTypCd = request.getParameter("insTypCd");//保险种类
        if (StringUtils.isEmpty(prjPrdDtlId)||StringUtils.isEmpty(insTypCd)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("验证是否已录入选中险种失败");
            return result;
        }
        BaseLogUtils.info(logger, "validateInsTyp", "验证项目产品对应的保险险种是否已录入：" + prjPrdDtlId + "," + insTypCd, CurrentThreadContext.getCurrentUserName());
        //接入贷前接口
        cn.fl.preloan.condition.InsPlcBscInfoQueryCondition condition = new cn.fl.preloan.condition.InsPlcBscInfoQueryCondition();
        condition.setPrjPrdDtlId(Long.valueOf(prjPrdDtlId));
        condition.setInsTypCd(insTypCd);
        condition.setSysCd(CurrentThreadContext.getCurrentSysCd());
        condition.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
        GetInsPlcBscInfoListRequest listRequest = new GetInsPlcBscInfoListRequest(condition);
        ResponseData responseData = iInsPlcBscInfoService.searchList(listRequest);
        BaseLogUtils.info(logger, "searchList", "贷前--request：" + JSONObject.toJSONString(listRequest) + "response" + JSONObject.toJSONString(responseData), CurrentThreadContext.getCurrentUserName());
        List<InsPlcBscInfoVO> voList = new ArrayList<>();
        InsPlcBscInfoVO insPlcBscInfoVO = null;
        if (responseData != null && responseData.getData() != null) {
            List<InsPlcBscInfoDTO> list = (List<InsPlcBscInfoDTO>) responseData.getData();
            for (InsPlcBscInfoDTO insPlcBscInfoDTO : list) {
                insPlcBscInfoVO = new InsPlcBscInfoVO();
                BeanUtils.copyProperties(insPlcBscInfoDTO,insPlcBscInfoVO);
                voList.add(insPlcBscInfoVO);
            }
        }
        result.setData(voList);
        /*result.setData(this.insPlcBscInfoService.validateInsTyp(Long.valueOf(prjPrdDtlId), insTypCd));*/
        return result;
    }

    /**
     * 验证保险公司是否设置渠道信息
     *
     * @param request
     * @param response
     * @return
     * @throws BaseException
     */
    @RequestMapping(value = "/getInsSubCompType.do", method = {RequestMethod.POST})
    @ResponseBody
    public DataResultVO getInsSubCompType(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "查询成功");
        InsChnOpenSettingQueryCondition condition = new InsChnOpenSettingQueryCondition();
        String prjTypCd = request.getParameter("prjTypCd");
        if (StringUtils.isNotBlank(prjTypCd)) {
            condition.setPrjTypCd(prjTypCd);
        }
        String bizTypCd = request.getParameter("bizTypCd");
        if (StringUtils.isNotBlank(bizTypCd)) {
            condition.setBizTypCd(bizTypCd);
        }
        String plcTypCd = request.getParameter("plcTypCd");
        if (StringUtils.isNotBlank(plcTypCd)) {
            condition.setPlcTypCd(plcTypCd);
        }
        String insTypCd = request.getParameter("insTypCd");
        if (StringUtils.isNotBlank(insTypCd)) {
            condition.setInsTypCd(insTypCd);
        }
        /*String rgnCd=request.getParameter("rgnCd");
        if(StringUtils.isNotBlank(rgnCd)){
            condition.setRgnCd(rgnCd);
        }*/
        String orgCd = request.getParameter("orgCd");
        if (StringUtils.isNotBlank(orgCd)) {
            condition.setBuOrgCd(orgCd);
        }
        condition.setExpDt(DateUtils.formatDateToString(new Date(), DateUtils.YYYY_MM_DD));
        condition.setIsValid(BaseConstant.IS_YESNO_YES);
        List<InsChnOpenSettingVO> list = insChnOpenSettingService.searchList(condition);
        if (CollectionUtils.isNotEmpty(list)) {
            result.setData(list.get(0).getId());
        }
        return result;
    }

    /**
     * 获取请求参数
     *
     * @param request 请求
     * @return
     */
    private InsPlcBscInfoVO getRequestParamForInsPlcBscInfo(HttpServletRequest request) throws BaseException {
        //获取参数
        String id = request.getParameter("id");//保单主键
        String plcNo = request.getParameter("plcNo");//保单号
        String insTypCd = request.getParameter("insTypCd");//保单险种
        String insCompId = request.getParameter("insCompId");//保险公司ID
        String insCompSubId = request.getParameter("insCompSubId");//保险支公司ID
        String insCompSubNm = request.getParameter("insCompSubNm");//保险支公司名称
        String buyWayCd = request.getParameter("buyWayCd");//购买方式
        String insPerNm = request.getParameter("insPerNm");//被保险人
        String insPerCretNo = request.getParameter("insPerCretNo");//被保险人证件号
        String insTtlFee = request.getParameter("insTtlFee");//总保费
        String plcBgTm = request.getParameter("plcBgTm");//起始时间
        String plcEndTm = request.getParameter("plcEndTm");//截止时间
        String plcExpCd = request.getParameter("plcExpCd");//期限
        String plcPropCd = request.getParameter("plcPropCd");//性质
        String plcRem = request.getParameter("plcRem");//备注
        String prdTypCd = request.getParameter("prdTypCd");//产品类型
        String fstPer = request.getParameter("fstPer");//第一受益人
        String fileParams = request.getParameter("fileParams");//附件上传信息
        String paySchId = request.getParameter("paySchId");//支付表ID
        String paySchNo = request.getParameter("paySchNo");//支付表号
        String rgnCyCd = request.getParameter("rgnCyCd");//城市
        String rgnPrCd = request.getParameter("rgnPrCd");//省份
        String plcSpePolCd = request.getParameter("plcSpePolCd");//特殊政策
        String renewId = request.getParameter("renewId");//续保ID
        String chnPol = request.getParameter("chnPol");//渠道政策编号
        String plcId = request.getParameter("plcId");//待续保保单ID
        String prjId = request.getParameter("prjId");//项目ID
        String contNo = request.getParameter("contNo");//合同号
        String cstAccNm = request.getParameter("cstAccNm");
        String cstAccNo = request.getParameter("cstAccNo");
        String bkNm = request.getParameter("bkNm");
        String bkNo = request.getParameter("bkNo");
        String bkAccRem = request.getParameter("bkAccRem");
        String isRene = request.getParameter("isRene");//是否计入续保

        String cstId = request.getParameter("cstId");
        String cstNm = request.getParameter("cstNm");
        String cstMgrNm = request.getParameter("cstMgrNm");
        String cstMgrId = request.getParameter("cstMgrId");
        String cstMgrOrgCd = request.getParameter("cstMgrOrgCd");
        String buOrgCd = request.getParameter("buOrgCd");
        String prjPrdDtlId = request.getParameter("prjPrdDtlId");

        //验证参数并赋值
        InsPlcBscInfoVO entity = new InsPlcBscInfoVO();
        /*if (StringUtils.isBlank(plcNo)) {
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "保单号不能为空.");
        }*/
        if (StringUtils.isNotBlank(cstNm)) {
            entity.setCstNm(cstNm);
        }
        if(StringUtils.isNotEmpty(cstId)){
            entity.setCstId(Long.parseLong(cstId));
        }
        if(StringUtils.isNotEmpty(cstMgrId)){
            entity.setCstMgrId(Long.parseLong(cstMgrId));
        }
        if (StringUtils.isNotBlank(cstMgrNm)) {
            entity.setCstMgrNm(cstMgrNm);
        }
        if (StringUtils.isNotBlank(cstMgrOrgCd)) {
            entity.setCstMgrOrgCd(cstMgrOrgCd);
        }
        if (StringUtils.isNotBlank(buOrgCd)) {
            entity.setBuOrgCd(buOrgCd);
        }
        if(StringUtils.isNotEmpty(prjPrdDtlId)){
            entity.setPrjPrdDtlId(Long.parseLong(prjPrdDtlId));
        }

        if (StringUtils.isNotBlank(plcNo)) {
            entity.setPlcNo(plcNo);
        } else {
            entity.setPlcNo("");
        }
        entity.setInsTypCd(insTypCd);
        entity.setPrdTypCd(prdTypCd);
        entity.setCstMgrRgnCd(CurrentThreadContext.getCurrentRgnDivCd());
        if (StringUtils.isBlank(insCompId)) {
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "保险公司不能为空.");
        }
        entity.setInsCompId(Long.valueOf(insCompId));
        if (StringUtils.isBlank(insCompSubId)) {
            if (InsuranceConstant.CODE_INS_BUY_WAY_CD_1.equals(buyWayCd)) {//我司购买保险支公司不能为空
                throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "保险支公司不能为空.");
            }
        } else {
            entity.setInsCompSubId(Long.valueOf(insCompSubId));
        }
        entity.setInsCompSubNm(insCompSubNm);

        //解析附件上传信息
        if (StringUtils.isNotBlank(fileParams)) {
            List<Map<String, String>> fileParamsList = new ArrayList<Map<String, String>>();
            JSONArray arry = JSONArray.fromObject(fileParams);
            for (int i = 0; i < arry.size(); i++) {
                net.sf.json.JSONObject jsonObject = arry.getJSONObject(i);
                Iterator<?> it = jsonObject.keys();
                HashMap<String, String> hMap = new HashMap<String, String>();
                while (it.hasNext()) {
                    String key = String.valueOf(it.next());
                    String value = (String) jsonObject.get(key);
                    hMap.put(key, value);
                }
                fileParamsList.add(hMap);
            }
            List<SysUlFilesRecVO> sysUlFilesRecVOList = new ArrayList<SysUlFilesRecVO>();
            String rootPath = PropertiesCacheUtils.getProperty(SysUlFilesRecConstant.SYS_FILE_UPLOAD_ROOT_PATH);
            for (Map<String, String> map : fileParamsList) {
                SysUlFilesRecVO sysUlFilesRecVO = new SysUlFilesRecVO();
                sysUlFilesRecVO.setFileNm(map.get("fileNm"));
                sysUlFilesRecVO.setFilePath(map.get("filePath"));
                sysUlFilesRecVO.setOrgCd("0000");//默认不区分
                sysUlFilesRecVO.setSysCd(CurrentThreadContext.getCurrentSysCd());
                sysUlFilesRecVO.setCfgCd(map.get("cfgCd"));
                sysUlFilesRecVO.setCfgDtlCd(map.get("cfgDtlCd"));
                sysUlFilesRecVO.setCrtUsrRlNm(CurrentThreadContext.getCurrentUserName());
                sysUlFilesRecVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                sysUlFilesRecVO.setCrtTm(new Date());
                sysUlFilesRecVO.setAbsLocPath(rootPath+sysUlFilesRecVO.getFilePath());
                sysUlFilesRecVOList.add(sysUlFilesRecVO);
            }
            entity.setSysUlFilesRecVOList(sysUlFilesRecVOList);
        } /*else {
            if (StringUtils.isBlank(id)) {
                throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "请上传电子保单.");
            }
        }*/

        entity.setBuyWayCd(buyWayCd);
        entity.setPlcPropCd(plcPropCd);
        if (StringUtils.isNotBlank(plcPropCd) && InsuranceConstant.CODE_INS_PLC_NAT_CD_2.equals(plcPropCd)) {
            entity.setStlStsCd(InsuranceConstant.CODE_INS_PLC_STL_STS_CD_20);
        }
        entity.setPlcExpCd(plcExpCd);
        if(StringUtils.isNotBlank(plcBgTm)){
            entity.setPlcBgTm(DateUtils.formatStringToDate(plcBgTm, DateUtils.YYYY_MM_DD));
        }
        if(StringUtils.isNotBlank(plcBgTm)) {
            entity.setPlcEndTm(DateUtils.formatStringToDate(plcEndTm, DateUtils.YYYY_MM_DD));
        }
        entity.setInsPerNm(insPerNm);
        entity.setInsPerCretNo(insPerCretNo);
        entity.setPlcRem(plcRem);
        if(StringUtils.isNotBlank(fstPer)){
            entity.setFstPer(fstPer);
        }else{
            entity.setFstPer(InsuranceConstant.CODE_INS_PLC_FST_PER_DEFAULT_CD_NM);
        }
        /*List<KeyValueVO> fstPerTypCdList = this.insPlcBscInfoService.searchInsFstPerTypCdList();//保单第一受益人
        if(CollectionUtils.isNotEmpty(fstPerTypCdList)){
            if(StringUtils.isNotBlank(fstPer)){
                for(KeyValueVO keyValueVO : fstPerTypCdList){
                    if(keyValueVO.getKey().equals(fstPer)){
                        entity.setFstPer(keyValueVO.getValue());
                    }
                }
            }else{
                entity.setFstPer(InsuranceConstant.CODE_INS_PLC_FST_PER_DEFAULT_CD_NM);
            }
        }else{
            entity.setFstPer(InsuranceConstant.CODE_INS_PLC_FST_PER_DEFAULT_CD_NM);
        }*/
        if (StringUtils.isNotBlank(rgnCyCd)) {
            entity.setRgnCyCd(rgnCyCd);
        } else {
            entity.setRgnCyCd("");
        }
        if (StringUtils.isNotBlank(rgnPrCd)) {
            entity.setRgnPrCd(rgnPrCd);
        } else {
            entity.setRgnPrCd("");
        }

        if (StringUtils.isNotBlank(paySchId)) {
            entity.setPaySchId(Long.valueOf(paySchId));
        }
        if (StringUtils.isNotBlank(paySchNo)) {
            entity.setPaySchNo(paySchNo);
        }
        if (StringUtils.isNotEmpty(insTtlFee)) {
            entity.setInsTtlFee(DecimalUtils.convertYuanToFen(Double.valueOf(insTtlFee)));
        }
        if (StringUtils.isNotBlank(plcSpePolCd)) {
            entity.setPlcSpePolCd(plcSpePolCd);
        }
        if (StringUtils.isNotEmpty(renewId)) {
            entity.setRenewId(Long.parseLong(renewId));
        }
        if (StringUtils.isNotEmpty(chnPol)) {
            entity.setChnPol(Long.parseLong(chnPol));
        }
        if (StringUtils.isNotEmpty(plcId)) {
            entity.setPlcId(Long.parseLong(plcId));
        }
        if (StringUtils.isNotEmpty(prjId)) {
            entity.setPrjId(Long.parseLong(prjId));
        }
        if (StringUtils.isNotBlank(contNo)) {
            entity.setContNo(contNo.trim());
        }
        if (StringUtils.isNotBlank(cstAccNm)) {
            entity.setCstAccNm(cstAccNm.trim());
        }
        if (StringUtils.isNotBlank(cstAccNo)) {
            entity.setCstAccNo(cstAccNo.trim());
        }
        if (StringUtils.isNotBlank(bkNm)) {
            entity.setBkNm(bkNm.trim());
        }
        if (StringUtils.isNotBlank(bkNo)) {
            entity.setBkNo(bkNo.trim());
        }
        if (StringUtils.isNotBlank(bkAccRem)) {
            entity.setBkAccRem(bkAccRem.trim());
        }
        if(StringUtils.isNotEmpty(isRene)){
            entity.setIsRene(Integer.parseInt(isRene));
        }

        //换车页面保存保单信息时不绑定项目和支付表
        String prjPrdChangeFlag = request.getParameter("prjPrdChangeFlag");
        if ("true".equals(prjPrdChangeFlag)) {
            entity.setPrjId(null);
            entity.setPaySchId(null);
            entity.setPaySchNo(null);
        }

        //保单产品信息
        String insPrds = request.getParameter("insPrd");
        if (StringUtils.isNotBlank(insPrds)) {
            List<PrjPrdDtlForInsVO> prjPrdDtlForInsVOList = JSON.parseArray(insPrds, PrjPrdDtlForInsVO.class);
            List<InsPlcPrdDtlTkVO> prdDtlTkVOList = new ArrayList<>();
            InsPlcPrdDtlTkVO plcPrdDtlTkVO;
            for (PrjPrdDtlForInsVO vo : prjPrdDtlForInsVOList) {
                plcPrdDtlTkVO = new InsPlcPrdDtlTkVO();
                plcPrdDtlTkVO.setPrjPrdDtlId(vo.getPrjPrdDtlId());//项目产品明细ID
                plcPrdDtlTkVO.setCertNo(vo.getCertNo());//合格证编号
                plcPrdDtlTkVO.setChsNo(vo.getChsNo()); //底盘号
                plcPrdDtlTkVO.setEngNo(vo.getEngNo()); //发动机号
                plcPrdDtlTkVO.setEngMdl(vo.getEngMdl()); //发动机型号
                plcPrdDtlTkVO.setMfrNm(vo.getMfrNm()); //厂商名称
                plcPrdDtlTkVO.setSplNm(vo.getSplNm()); //供应商名称
                plcPrdDtlTkVO.setPrdPrc(vo.getPrdPrc()); //单价
                plcPrdDtlTkVO.setPrdNm(vo.getPrdNm()); //产品名称
                plcPrdDtlTkVO.setPrdMdl(vo.getPrdMdl()); //产品型号
                plcPrdDtlTkVO.setMachNo(vo.getMachNo());//整机号
                plcPrdDtlTkVO.setVinNo(vo.getVinNo());//车架号
                plcPrdDtlTkVO.setPrdTypCd(vo.getPrdTypCd());//产品类型代码
                plcPrdDtlTkVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                plcPrdDtlTkVO.setCrtTm(new Date());
                prdDtlTkVOList.add(plcPrdDtlTkVO);
            }
            entity.setInsPlcPrdDtlTkVOList(prdDtlTkVOList);//保单项目产品
            entity.setCstId(prjPrdDtlForInsVOList.get(0).getCstId());//客户ID
            entity.setCstNm(prjPrdDtlForInsVOList.get(0).getCstNm());//客户名称
        } /*else {
            if (StringUtils.isBlank(id)) {
                //新增保单必须有产品信息
                throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "未找到保单产品信息.");
            }
        }*/

        //保单险种信息
        String insTyps = request.getParameter("insTyp");
        if (StringUtils.isNotBlank(insTyps)) {
            List<InsPlcTypDtlVO> insPlcTypDtlVOList = JSON.parseArray(insTyps, InsPlcTypDtlVO.class);
            //验证险种唯一
            StringBuffer strbuf = new StringBuffer();
            for (InsPlcTypDtlVO vo : insPlcTypDtlVOList) {
                if (strbuf.toString().contains(vo.getInsTypId().toString())) {
                    throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "保单险种重复.");
                }
                strbuf.append(vo.getInsTypId() + ";");
                if (vo.getInsAmtDb() == null) {
                    vo.setInsAmt(0l);
                } else {
                    vo.setInsAmtDb(DecimalUtils.mul(vo.getInsAmtDb(), 100d));
                    vo.setInsAmt(vo.getInsAmtDb().longValue());
                }
                if (vo.getInsFeeDb() == null) {
                    vo.setInsFee(0l);
                } else {
                    vo.setInsFeeDb(DecimalUtils.mul(vo.getInsFeeDb(), 100d));
                    vo.setInsFee(vo.getInsFeeDb().longValue());
                }
                if (StringUtils.isEmpty(vo.getIsNonDedu())) {//不计免赔 默认否
                    vo.setIsNonDedu(0);
                }
            }
            entity.setInsPlcTypDtlVOList(insPlcTypDtlVOList);
        }
        /*else {
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "保单险种不能为空.");
        }*/

        Date tm = new Date();
        if (StringUtils.isNotBlank(id)) {
            entity.setId(Long.valueOf(id));
            entity.setMdfTm(tm);
            entity.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
        } else {
            entity.setCrtTm(tm);
            entity.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
            /*entity.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
            entity.setCstMgrOrgCd(CurrentThreadContext.getCurrentOrgCd());
            entity.setCstMgrNm(CurrentThreadContext.getCurrentUserName());
            entity.setCstMgrId(CurrentThreadContext.getCurrentUserId());*/
        }
        return entity;
    }

    /**
     * 发起续保申请
     *
     * @param request
     * @param response
     * @return
     * @throws BaseException
     */
    @RequestMapping(value = "/startRenewApply.do", method = {RequestMethod.POST})
    @ResponseBody
    public DataResultVO startRenewApply(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "流程发起成功");
        String id = request.getParameter("id");
        if (StringUtils.isEmpty(id)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("请先保存保单信息");
            return result;
        }
        InsPlcBscInfoQueryCondition condition = new InsPlcBscInfoQueryCondition();
        condition.setId(Long.parseLong(id));
        result = this.insPlcBscInfoService.addRenewApply(condition);
        return result;
    }

    /**
     * 保存保证金处理方式
     *
     * @param request
     * @param response
     * @return
     * @throws BaseException
     */
    @RequestMapping(value = "/saveHandleWay.do", method = {RequestMethod.POST})
    @ResponseBody
    public DataResultVO saveHandleWay(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "保存成功");
        String id = request.getParameter("id");//保单ID
        String paySchDId = request.getParameter("paySchDId");//支付表明细ID
        String feeAmt = request.getParameter("feeAmt");//处理金额
        String feeTypCd = request.getParameter("feeTypCd");//费用类型
        String paySchId = request.getParameter("paySchId");//支付表ID
        String paySchNo = request.getParameter("paySchNo");//支付表号
        String handleWayCd = request.getParameter("handleWayCd");//处理方式

        if (StringUtils.isEmpty(handleWayCd)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("请选择处理方式");
            return result;
        }

        InsPlcBscInfoQueryCondition condition = new InsPlcBscInfoQueryCondition();
        condition.setHandldWayCd(handleWayCd);
        if (StringUtils.isNotEmpty(id)) {
            condition.setId(Long.parseLong(id));
        }
        if (StringUtils.isNotEmpty(paySchId)) {
            condition.setPaySchId(Long.parseLong(paySchId));
        }
        if (StringUtils.isNotEmpty(paySchDId)) {
            condition.setPaySchDId(Long.parseLong(paySchDId));
        }
        if (StringUtils.isNotBlank(paySchNo)) {
            condition.setPaySchNo(paySchNo);
        }
        if (StringUtils.isNotBlank(feeTypCd)) {
            condition.setFeeTypCd(feeTypCd);
        }
        if (StringUtils.isNotEmpty(feeAmt)) {
            Double amt = Double.parseDouble(feeAmt);
            condition.setFeeAmt(amt.longValue());
        }
        BaseLogUtils.info(logger, "saveHandleWay", "保存保证金处理方式：" + JSON.toJSONString(condition), CurrentThreadContext.getCurrentUserName());
        result = this.insPlcBscInfoService.modifyHandleWay(condition);
        BaseLogUtils.info(logger, "saveHandleWay", "保存保证金处理方式返回=" + JSON.toJSONString(result));
        return result;
    }

    /**
     * 保存收款银行账号信息
     *
     * @param request
     * @param response
     * @return
     * @throws BaseException
     */
    @RequestMapping(value = "/saveBkInfo.do", method = {RequestMethod.POST})
    @ResponseBody
    public DataResultVO saveBkInfo(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "保存成功");
        String id = request.getParameter("id");//保单ID
        String cstAccNm = request.getParameter("cstAccNm");//账户名称
        String cstAccNo = request.getParameter("cstAccNo");//账号
        String bkNm = request.getParameter("bkNm");//开户支行
        String bkNo = request.getParameter("bkNo");//开户行号
        String bkAccRem = request.getParameter("bkAccRem");//备注

        InsPlcBscInfoVO entity = new InsPlcBscInfoVO();
        if (StringUtils.isNotEmpty(id)) {
            entity.setId(Long.parseLong(id));
        } else {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("未找到保单信息");
            return result;
        }

        if (StringUtils.isNotBlank(cstAccNm)) {
            entity.setCstAccNm(cstAccNm.trim());
        }
        if (StringUtils.isNotBlank(cstAccNo)) {
            entity.setCstAccNo(cstAccNo.trim());
        }
        if (StringUtils.isNotBlank(bkNm)) {
            entity.setBkNm(bkNm.trim());
        }
        if (StringUtils.isNotBlank(bkNo)) {
            entity.setBkNo(bkNo.trim());
        }
        if (StringUtils.isNotBlank(bkAccRem)) {
            entity.setBkAccRem(bkAccRem.trim());
        }

        BaseLogUtils.info(logger, "saveBkInfo", "保存收款账户信息：" + JSON.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
        ModifyInsPlcBscInfoRequest modifyRequest = new ModifyInsPlcBscInfoRequest();
        InsPlcBscInfoDTO dto = new InsPlcBscInfoDTO();
        BeanUtils.copyProperties(entity,dto);
        modifyRequest.setInsPlcBscInfoDTO(dto);
        ResponseData responseData = iInsPlcBscInfoService.modifyInsPlcBscInfo(modifyRequest);
        BaseLogUtils.newLogger("修改保单信息，dto:{},response:{}", JSON.toJSONString(dto), JSON.toJSONString(responseData)).info();
        if (null == responseData || !ResponseData.SUCCESS_CODE.equals(responseData.getCode())){
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("保存失败");
        }
        BaseLogUtils.info(logger, "saveBkInfo", "保存收款账户信息=" + JSON.toJSONString(result));
        return result;
    }


    /**
     * 到保险管理列表页面
     */
    @RequestMapping(value = "/toPlcPage.do", method = {RequestMethod.GET})
    public ModelAndView toPlcListPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toListPage", "加载保险管理列表页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("insurance/insPlcBscInfo/insInsureListInFlow");
        String prjId=request.getParameter("prjId");//项目ID
        String payId=request.getParameter("payId");//付款ID
        String paySchId = request.getParameter("paySchId");//支付表ID
        String operateInsPlc = request.getParameter("operateInsPlc");//是否可操作保单
        mav.addObject("prjId",prjId);
        mav.addObject("payStsCd",CapitalConstant.CODE_CAP_PAY_STS_CD_3);
        mav.addObject("operateInsPlc",operateInsPlc);
        if(StringUtils.isNotEmpty(payId)){
            CapPayInfoVO payInfoVO = this.capPayInfoService.selectById(Long.valueOf(payId));
            if(null != payInfoVO){
                mav.addObject("paySchId",payInfoVO.getPaySchId());
                mav.addObject("prjId",payInfoVO.getPrjId());
            }
        }
        //准时放款业务
        if(StringUtils.isNotBlank(paySchId)){
        	PrjPrdPaySchMVO prjPrdPaySchMVO = this.prjPrdPaySchMService.selectById(Long.valueOf(paySchId));
        	if(null!=prjPrdPaySchMVO){
        		mav.addObject("paySchId",paySchId);
                mav.addObject("prjId",prjPrdPaySchMVO.getPrjId());
                mav.addObject("payStsCd","");
        	}
        }
        return mav;
    }

    /**
     * 初始化列表
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/searchList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object searchList(HttpServletRequest request, HttpServletResponse response) {
        cn.fl.preloan.condition.InsPlcBscInfoQueryCondition qc = new cn.fl.preloan.condition.InsPlcBscInfoQueryCondition();
        //设置查询条件？
        String plcNo = request.getParameter("plcNo");//保单号
        String insCompNm = request.getParameter("insCompNm");//保险公司名称
        String paySchNo = request.getParameter("paySchNo");//支付表号
        String cstNm = request.getParameter("cstNm");
        String cstMgrNm = request.getParameter("cstMgrNm");
        String insCompId = request.getParameter("insCompId");
        String prjId=request.getParameter("prjId");
        String payStsCd=request.getParameter("payStsCd");
        String paySchId = request.getParameter("paySchId");

        if (StringUtils.isNotBlank(plcNo)) {
            qc.setPlcNo(plcNo);
        }
        if (StringUtils.isNotBlank(insCompNm)) {
            qc.setInsCompNm(insCompNm);
        }
        if (StringUtils.isNotBlank(paySchNo)) {
            qc.setPaySchNo(paySchNo);
        }
        if (StringUtils.isNotBlank(cstNm)) {
            qc.setCstNm(cstNm);
        }
        if (StringUtils.isNotBlank(cstMgrNm)) {
            qc.setCstMgrNm(cstMgrNm);
        }
        if (StringUtils.isNotEmpty(insCompId)) {
            qc.setInsCompId(Long.valueOf(insCompId));
        }
        if(StringUtils.isNotEmpty(prjId)){
            qc.setPrjId(Long.parseLong(prjId));
        }
        if(StringUtils.isNotEmpty(payStsCd)){
            qc.setPayStsCd(payStsCd);
        }
        if(StringUtils.isNotEmpty(paySchId)){
            qc.setPaySchId(Long.valueOf(paySchId));
        }

        qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
        qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
        qc.setUsrId(CurrentThreadContext.getCurrentUserId());

        BaseLogUtils.info(logger, "initInsPlcBscInfoList", "初始化InsPlcBscInfo列表页面数据(不分页).", CurrentThreadContext.getCurrentUserName());
        GetInsPlcBscInfoListRequest getListRequest = new GetInsPlcBscInfoListRequest(qc);
        getListRequest.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
        getListRequest.setSysCd(CurrentThreadContext.getCurrentSysCd());
        BaseLogUtils.info(logger, "searchList", "贷前--获取保单数据，request:" + JSONObject.toJSONString(getListRequest), CurrentThreadContext.getCurrentUserName());
        ResponseData<List<InsPlcBscInfoDTO>> infoResponse = iInsPlcBscInfoService.searchList(getListRequest);
        BaseLogUtils.info(logger, "searchList", "贷前--获取保单数据,response:" + JSONObject.toJSONString(infoResponse), CurrentThreadContext.getCurrentUserName());
        List<InsPlcBscInfoVO> list = null;
        if (null != infoResponse && ResponseData.SUCCESS_CODE.equals(infoResponse.getCode()) && CollectionUtils.isNotEmpty(infoResponse.getData())){
            List<InsPlcBscInfoDTO> data = infoResponse.getData();
            list = new ArrayList<>(data.size());
            InsPlcBscInfoVO vo = null;
            for (InsPlcBscInfoDTO datum : data) {
                vo = new InsPlcBscInfoVO();
                BeanUtils.copyProperties(datum,vo);
                list.add(vo);
            }
        }
        ListPageVO<InsPlcBscInfoVO> listPage = null;
        if(CollectionUtils.isNotEmpty(list)){
            listPage=new ListPageVO<InsPlcBscInfoVO>(list,list.size());
        }else{
            listPage=new ListPageVO<InsPlcBscInfoVO>(new ArrayList<InsPlcBscInfoVO>(0),0);
        }
        return listPage;
    }

    /**
     * 初始化保单资料列表
     */
    @RequestMapping(value = "/initPlcCfgFileList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initPlcCfgFileList(HttpServletRequest request, HttpServletResponse response) {
        String id = request.getParameter("id");//保单ID
        String cfgCd = request.getParameter("cfgCd");//配置编号
        String buOrgCd = request.getParameter("buOrgCd");//所属事业部
        if(StringUtils.isBlank(cfgCd)||StringUtils.isBlank(buOrgCd)){
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "请求参数不完整");
        }

        InsPlcBscInfoQueryCondition condition=new InsPlcBscInfoQueryCondition();
        if(StringUtils.isNotEmpty(id)){
            condition.setId(Long.valueOf(id));
        }
        condition.setCfgCd(cfgCd);
        condition.setBuOrgCd(buOrgCd);

        BaseLogUtils.info(logger, "initPrjPrdDtlFileInfoList", "初始化保单资料列表.", CurrentThreadContext.getCurrentUserName());
        List<PlcFileInfoVO> list = this.insPlcBscInfoService.searchPlcCfgFileInfoList(condition);
        if (CollectionUtils.isNotEmpty(list)) {
            return new ListPageVO<PlcFileInfoVO>(list, list.size());
        }
        return new ListPageVO<PlcFileInfoVO>(new ArrayList<PlcFileInfoVO>(), 0);
    }

    /********************
     * 上传保单资料文件
     *******************/
    @RequestMapping(value = "/uploadPlcFile.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object uploadPlcFile(HttpServletRequest request) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_FILE_UPLOAD_SUCC);
        String fileParams = request.getParameter("fileParams");
        String cfgCd = request.getParameter("cfgCd");
        String cfgDtlCd = request.getParameter("cfgDtlCd");
        String id = request.getParameter("id");//保单ID
        String orgCd = request.getParameter("orgCd");//所属事业部
        if (StringUtils.isBlank(id)) {
            BaseLogUtils.error(logger, "uploadPlcFile", "上传保单资料文件失败,主键ID为空==>cfgCd=" + cfgCd + ",cfgDtlCd=" + cfgDtlCd);
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_FILE_UPLOAD_FAIL);
        } else {
            boolean flag = this.sysUlFilesRecService.addAttchmnt(id, fileParams, cfgCd, cfgDtlCd, "INS_PLC_BSC_INFO", null, null, null, false, orgCd);
            if (!flag) {
                BaseLogUtils.error(logger, "uploadPlcFile", "上传保单资料文件失败==>id=" + id + ",cfgCd=" + cfgCd + ",cfgDtlCd=" + cfgDtlCd + ",file=" + fileParams);
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_FILE_UPLOAD_FAIL);
                return result;
            }
            BaseLogUtils.info(logger, "uploadPlcFile", "上传保单资料文件成功==>id=" + id + ",cfgCd=" + cfgCd + ",cfgDtlCd=" + cfgDtlCd);
        }
        return result;
    }

    /**
     * 删除保单资料
     *
     * @param request
     * @param response
     * @return
     * @throws BaseException
     */
    @RequestMapping(value = "/removePlcFile.do", method = {RequestMethod.POST})
    @ResponseBody
    public DataResultVO removePlcFile(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
        String fileId = request.getParameter("fileId");
        if (StringUtils.isEmpty(fileId)) {
            BaseLogUtils.info(logger, "removePlcFile", "删除保单资料==>资料ID为空");
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DELETE_FAIL);
            return result;
        }

        boolean success = this.insPlcBscInfoService.removePlcFile(Long.valueOf(fileId));
        BaseLogUtils.info(logger, "removePlcFile", "删除保单资料,id=" + fileId + ",success=" + success, CurrentThreadContext.getCurrentUserName());
        if (!success) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DELETE_FAIL);
        }
        return result;
    }



    /**
     * 到系统运维保单信息管理列表页面
     */
    @RequestMapping(value = "/toListPageSystem.do", method = {RequestMethod.GET})
    public ModelAndView toListPageSystem(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toListPageSystem", "加载保险管理列表页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("insurance/insPlcBscInfo/insPlcBscInfoListSystem");
        //保险公司
        InsCompInfoQueryCondition qc = new InsCompInfoQueryCondition();
        qc.setCompLvl(1);
        List<InsCompInfoDTO> insCompList = this.insCompInfoService.searchList(qc);
        if (CollectionUtils.isNotEmpty(insCompList)) {
            mav.addObject("insCompList", JSON.toJSONString(InsCompInfoVOTransform.toVOList(insCompList)));
        }
        return mav;
    }


    /**
     * 到系统运维保单信息修改保单页面
     */
    @RequestMapping(value = "/toModifyPageSystem.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toModifyPageSystem(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toModifyPageSystem", "加载到修改保单页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("insurance/insPlcBscInfo/insPlcBscInfoModifySystem");
        this.prepare(request, mav);

        String id = request.getParameter("id");
        if(StringUtils.isEmpty(id)){
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "保单主键为空");
        }
        InsPlcBscInfoVO insPlcBscInfoVO = new InsPlcBscInfoVO();
        GetInsPlcBscInfoRequest getRequest = new GetInsPlcBscInfoRequest();
        getRequest.setId(Long.parseLong(id));
        ResponseData<InsPlcBscInfoDTO> responseData = this.iInsPlcBscInfoService.selectById(getRequest);
        InsPlcBscInfoVO plcBscInfoVO = new InsPlcBscInfoVO();
        if (null != responseData && ResponseData.SUCCESS_CODE.equals(responseData.getCode()) && null != responseData.getData()){
            InsPlcBscInfoDTO dto = responseData.getData();
            BeanUtils.copyProperties(dto,plcBscInfoVO);
        }
        if (insPlcBscInfoVO.getPlcBgTm() != null) {
            insPlcBscInfoVO.setPlcBgTms(DateUtils.formatDateToString(insPlcBscInfoVO.getPlcBgTm(), DateUtils.YYYY_MM_DD));
        }
        if (insPlcBscInfoVO.getPlcEndTm() != null) {
            insPlcBscInfoVO.setPlcEndTms(DateUtils.formatDateToString(insPlcBscInfoVO.getPlcEndTm(), DateUtils.YYYY_MM_DD));
        }
        if (insPlcBscInfoVO.getInsTtlFee() != null) {
            insPlcBscInfoVO.setInsTtlFeeDb(DecimalUtils.convertFenToYuan(insPlcBscInfoVO.getInsTtlFee()));
        }
        PrjPrdPaySchMVO prjPrdPaySchMVO = this.prjPrdPaySchMService.selectById(insPlcBscInfoVO.getPaySchId());
        String insPlcFstPerCd = "" ;
        if(null != prjPrdPaySchMVO){
            insPlcFstPerCd = prjPrdPaySchMVO.getBizFlag();
//            insPlcBscInfoVO.setFstPer(prjPrdPaySchMVO.getBizFlag());
        }else{
            insPlcFstPerCd = InsuranceConstant.CODE_INS_PLC_FST_PER_CD_1 ;
//            insPlcBscInfoVO.setFstPer(InsuranceConstant.CODE_INS_PLC_FST_PER_CD_1);
        }
        List<KeyValueVO> fstPerTypCdList = this.insPlcBscInfoService.searchInsFstPerTypCdList();//保单第一受益人
        if(CollectionUtils.isNotEmpty(fstPerTypCdList)){
            for(KeyValueVO vo : fstPerTypCdList){
                if(vo.getKey().equals(insPlcFstPerCd)){
                    insPlcBscInfoVO.setFstPer(vo.getValue());
                    break ;
                }
            }
        }
        if(null == insPlcBscInfoVO.getFstPer()){
            insPlcBscInfoVO.setFstPer(InsuranceConstant.CODE_INS_PLC_FST_PER_DEFAULT_CD_NM);
        }
        mav.addObject("insPlcBscInfoVO", insPlcBscInfoVO);
        mav.addObject("paySchId", insPlcBscInfoVO.getPaySchId());//支付表ID
        mav.addObject("paySchNo", insPlcBscInfoVO.getPaySchNo());//支付表号
        mav.addObject("prjPrdDtlId", insPlcBscInfoVO.getPrjPrdDtlId());//项目产品明细ID

        mav.addObject("prjId", insPlcBscInfoVO.getPrjId());
        PrjBscInfoVO prjBscInfoVO = this.insPlcBscInfoService.searchPrjBscInfo(insPlcBscInfoVO.getPrjId());
        if (null != prjBscInfoVO) {
            mav.addObject("prjTypCd", prjBscInfoVO.getPrjTypCd());
            mav.addObject("bizTypCd", prjBscInfoVO.getBizTypCd());
            //mav.addObject("rgnCd","0,"+prjBscInfoVO.getRgnPrCd()+","+prjBscInfoVO.getRgnCyCd());
            mav.addObject("orgCd", prjBscInfoVO.getCstMgrOrgCd());
            mav.addObject("buOrgCd",prjBscInfoVO.getBuOrgCd());

            //暂时处理一下
            if(InsuranceConstant.INS_PRJ_BU_ORG_CD_5.equals(prjBscInfoVO.getBuOrgCd())){
                mav.setViewName("insurance/insPlcBscInfo/insPlcBscInfoAdd");
            }else{
                //查询项目产品明细信息  (重复查询 待优化)
                PrjPrdDtlForInsQueryCondition qc = new PrjPrdDtlForInsQueryCondition();
                qc.setId(insPlcBscInfoVO.getPrjPrdDtlId());
                qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
                qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
                List<PrjPrdDtlForInsDTO> prdList = this.insPlcBscInfoService.searchInsurePrdList(qc);

                //项目产品类型 ：挂车标示 1.挂车 0.非挂车
                mav.addObject("isTrailer",BaseConstant.IS_YESNO_NO);
                if(CollectionUtils.isNotEmpty(prdList)){
                    PrjPrdDtlForInsDTO prjPrdDtlForInsDTO=prdList.get(0);
                    mav.addObject("actPrdId", prjPrdDtlForInsDTO.getActPrdId());//车辆实际ID

                    String prdTypCd = prjPrdDtlForInsDTO.getPrdTypCd();
                    if(StringUtils.isNotEmpty(prdTypCd)){
                        if(prdTypCd.startsWith(InsuranceConstant.CODE_PRD_TYP_CD_006)||prdTypCd.startsWith(InsuranceConstant.CODE_PRD_TYP_CD_014)
                                ||prdTypCd.startsWith(InsuranceConstant.CODE_PRD_TYP_CD_015)){
                            //挂车 不用上传交强险保单
                            mav.addObject("isTrailer",BaseConstant.IS_YESNO_YES);
                        }
                    }
                }
            }
        }
        mav.addObject("ctrlKey","1");//控制保单附件维护 1.可上传删除 2.审核
        return mav;
    }
}

